All Questions

Tagged with
Filter by
Sorted by
Tagged with
275 votes
11 answers
217k views

Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing

I had an Asp.Net core 2.2 project. Recently, I changed the version from .net core 2.2 to .net core 3.0 Preview 8. After this change I see this warning message: using 'UseMvc' to configure MVC is ...
Nick Mehrdad Babaki's user avatar
184 votes
7 answers
215k views

The default XML namespace of the project must be the MSBuild XML namespace

I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment. IDE Microsoft Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 ...
David Pine's user avatar
  • 24.1k
134 votes
3 answers
64k views

I'm lost. What happened to ASP.NET MVC 5?

I've been keeping my head down working on various projects and apparently Microsoft has been busy making some big changes and it's confusing the hell out of me. ASP.NET Core first came onto my radar ...
xr280xr's user avatar
  • 12.9k
121 votes
3 answers
175k views

How to use SqlClient in ASP.NET Core?

I am trying to use SQLClient library in the ASP.net Core but cant seem to get it working. I found this article online advising how to setup but its not working for me: http://blog.developers.ba/using-...
Rob's user avatar
  • 6,969
116 votes
22 answers
165k views

IIS: Handler "aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list

I used angular .net core 2.2 template to build an application. In localhost working fine, When I host to IIS I'm getting this error. I'm using IIS 10 to host the application. Error, HTTP Error 500.21 -...
Arun kumar's user avatar
  • 1,595
81 votes
4 answers
75k views

Is ApiController deprecated in .NET Core

Is it true that "ApiController will get deprecated in .NET Core"? Asking since I'm planning to use it in new projects.
Viji's user avatar
  • 2,629
77 votes
6 answers
93k views

Encrypted configuration in ASP.NET Core

With web.config going away, what is the preferred way to store sensitive info (passwords, tokens) in the configurations of a web app built using ASP.NET Core? Is there a way to automatically get ...
Ovi's user avatar
  • 2,710
54 votes
14 answers
167k views

How to set javascript variables using MVC4 with Razor

Can someone format the code below so that I can set srcript variables with c# code using razor? The below does not work, i've got it that way to make is easy for someone to help. @{int proID = 123; ...
Filling The Stack is What I DO's user avatar
43 votes
2 answers
125k views

How to set default page asp.net [duplicate]

I've just published my site in my server, but when I type in the browser www.mysite.com I get this error : HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of ...
Norman's user avatar
  • 453
40 votes
2 answers
27k views

.net Core X Forwarded Proto not working

I am working to get my .net core 1.1 application working behind a load balancer and enforcing https. I have the following setup in my Startup.cs public void Configure(IApplicationBuilder app, ...
Josh's user avatar
  • 2,308
39 votes
4 answers
46k views

Using .gitignore file to hide appsettings.json does not actually hide it

I have a C# MVC .Net Core application I'm building, the connection string is in a file called appsettings.json so what I want to do is simply exclude this from my git repository. I have added the ...
CrazyLegs's user avatar
  • 568
38 votes
4 answers
16k views

Login with ASP Identity fails every time with "Not Allowed" (even when 'email' and 'username' have the same value))

Registering a user works fine, as it logs in via this line: await _signInManager.SignInAsync(user, isPersistent: model.RememberMe); But if I want to log in with the same user again does not work (...
user avatar
32 votes
1 answer
11k views

Differences between ASP.NET Web Application (.NET Framework) vs ASP.NET Core Web Application (.NET Framework)

Why should I choose ASP.NET Web Application (.NET Framework) instead of ASP.NET Core Web Application (.NET Framework)? I'm talking about options 1 and 3 in the options below, what will be the ...
Tomer Peled's user avatar
  • 3,591
26 votes
2 answers
10k views

Visual Studio 2015 Web Application .NET Core vs .NET Framework

In Visual Studio Enterprise 2015 (v14.0.25123.00 Update 2) when I go to: Start > New Project With Target Framework 4.5 or higher selected... Under: Installed | |--> Visual C# | ...
Fernando Vega's user avatar
24 votes
10 answers
109k views

HTTP Error 500: localhost is currently unable to handle this request

I'm running into an HTPP Error 500 and I'm not sure why. When I start my service, I pop open a Chrome browser and navigate to http://localhost:5000, and the error pops up. The Chrome Developer Tools ...
Roka545's user avatar
  • 3,474
22 votes
1 answer
30k views

How to map config in IConfigurationSection to a simple class

Using MVC .net Core and building a concrete config class within the startup class. My appsettings.json looks like this: { "myconfig": { "other2": "tester, "other": "tester", "root": { ...
Rob's user avatar
  • 6,969
21 votes
1 answer
10k views

.NET Core Difference between Hosted Service and Singleton Service

From .NET Core 2.1 onward, we can now run background tasks with hosted service. I believe we could achieve same by adding a Service Class to service container with Singleton scope. What are the ...
Azaz ul Haq's user avatar
  • 1,667
19 votes
13 answers
34k views

Scaffolding error : deps.json doesn't exist

I'm currently using VS2017 for developing .NET Core MVC Web When I tried to create a new Controller from Add > Controller, I got this error Error There was an error running the code generator: "The ...
Muhamad Iqbal's user avatar
19 votes
4 answers
14k views

Asp.net core MVC post parameter always null

I am new to MVC core. I have created a project with MVC core which has a controller. This controller has Get and Post action methods. If i pass data to Get method using query string it works fine, ...
Ravi Patel's user avatar
19 votes
2 answers
9k views

.NET Core error on build: error MSB4062 Microsoft.Build.Tasks.ResolveComReference

I'm working on a .net core web app (targeting net461). The app needs to reference a COM dll. I added the COM reference and the app still builds on my dev machine. However, on the build server it ...
John-Luke Laue's user avatar
18 votes
1 answer
12k views

What's the difference between HttpContext.RequestAborted and CancellationToken parameter?

I'm trying to create an async view component for ASP.NET Core 2.0. It will do an action that should be cancelled when the user navigates away from the page. I've got the following options: Using the ...
Kees C. Bakker's user avatar
17 votes
5 answers
10k views

App redirects to Account/AccessDenied on adding Oauth

I've stumbled upon an issue where inconsistently the application redirects the user to Account/AccessDenied/ upon adding a social media authentication to the current logged in user. It seems to work ...
Rovdjuret's user avatar
  • 1,488
17 votes
7 answers
3k views

Asp.net Core Email confirmation sometimes says InvalidToken

I am using asp.net core identity 2.1 and i am having a random issue with email confirmation, which while email confirmation sometimes says result.Error = InvalidToken. The token is also not expired. ...
M.Tanzil's user avatar
  • 1,997
16 votes
4 answers
41k views

asp.net core web API file upload and "form-data" multiple parameter passing to method

I have created an endpoint that takes files as parameters: [HttpPost("[action]")] [Consumes("multipart/form-data")] public ActionResult UploadImage(IFormFile Files, string param) { ...
Dinuka Wanasinghe's user avatar
16 votes
2 answers
10k views

HttpContext.Response.Cache equivalent in .NET Core?

I'm trying to reproduce something I found here for a previous version of ASP.NET. Basically, I want to be able to disable cache so my client's look to the server for information at all times. I've ...
jackmusick's user avatar
15 votes
4 answers
14k views

InvalidOperationException on File return

am running into some weird issue when i try to return a file to be downloaded, so this is my code string filePath = Path.Combine(Path1, Path2, filename); return File(filePath, "audio/mp3", "myfile....
Jake Weary's user avatar
15 votes
2 answers
36k views

.NET Core Web API: multiple [FromBody]?

I am converting code that was written in ASP.NET MVC to ASP.NET Core MVC. While I was converting the code, I encountered a problem. We used a method that has multiple parameters like this: [HttpPost] ...
Burak çağlayan's user avatar
15 votes
4 answers
21k views

Read Asp.Net Core Response body in ActionFilterAttribute

I'm using Asp.Net Core as a Rest Api Service. I need access to request and response in ActionFilter. Actually, I found the request in OnActionExcecuted but I can't read the response result. I'm ...
Saeid Mirzaei's user avatar
15 votes
3 answers
10k views

.Net Core: Return IActionResult from a custom Exception Middleware

I have created a new Exception middleware in my .Net Core application. All the exceptions throughout the application are captured and logged here. What I want is to return a IActionResult type like ...
shaikhspear's user avatar
15 votes
3 answers
12k views

Migrating global.asax to ASP.NET 5

Few days ago .NET Core RC1 got released and I gave it a go for the first time after reading a lot about it, I like it but its a bit different. I am trying to migrate a small blog (built in MVC5) to ...
Cindro's user avatar
  • 1,065
14 votes
5 answers
39k views

.net Core 6 - Unable to resolve service for type while attempting to activate

In my ASP.NET Core application, I get the following error: InvalidOperationException: Unable to resolve service for type 'mvc_net6.Service.DB_Context' while attempting to activate 'mvc_net6....
r31sr4r's user avatar
  • 336
14 votes
3 answers
10k views

How to customize the docker image name in VS2019

In vs2019, I generate the docker image in the output window, the original command to generate the image was: docker build -f "e:\work\dotnetcoreproject\rookie.qwt\rookie.qwt.webapi\dockerfile" --...
pepperann's user avatar
  • 159
13 votes
6 answers
26k views

Post Multiple Parameters Without DTO Class

I have an action on my web project which calls to an API [HttpPost] public async Task<IActionResult> ExpireSurvey(int id) { var token = await HttpContext.GetTokenAsync("...
egmfrs's user avatar
  • 1,327
13 votes
1 answer
5k views

Swagger not generating model for object wrapped by IActionResult

With the following code, Swaggger UI shows the RegistrationInfo model but not the UserInfo model. How do I get that to generate? [Produces("application/json")] [Authorize(AuthenticationSchemes = ...
Kirsten's user avatar
  • 16.8k
13 votes
2 answers
19k views

Startup.cs - The path in 'value' must start with '/'

I have created a new .NET Core MVC application in Visual Studio 2017 and enabled multi-tenant authentication. I've completed the configuration (ClientId, Authority, etc) but when I debug the ...
Ben Short's user avatar
  • 401
13 votes
4 answers
12k views

asp-validation-summary not showing, field validation working

Im using dotnet core MVC and am having issues with asp-validation-summary. Validation is working at a field level using asp-validation-for however I am not getting anything showing up in the asp-...
Mike U's user avatar
  • 3,001
13 votes
1 answer
2k views

AddNewtonsoftJson is not overriding System.Text.Json

I have upgraded my version of .Net Core from preview 2 to preview 6 which has broken a couple of things. Most significant is that I cannot use newtonsoft JSON anymore. AddNewtonsoftJson in ...
craig's user avatar
  • 441
12 votes
1 answer
13k views

Unable to install packages using dotnet add package

I'm a .NET newbie using VS Code while following an online course on Angular and .NET Core. The course requires the AutoMapper.Extensions.Microsoft.DependencyInjection package to be installed but I ...
juanitooo's user avatar
  • 521
12 votes
3 answers
18k views

HTTP Error 404.13 - asp.net core 2.0

HTTP Error 404.13 - Not Found The request filtering module is configured to deny a request that exceeds the request content length. Verify the configuration/system.webServer/security/...
Aixasz's user avatar
  • 448
12 votes
1 answer
3k views

Images in Razor Class Library

Is it possible to use images and other file types such as css/js/etc. in a Razor Class library? I'm having an issue trying to get the images and css in the Razor Class Library to show up in a .Net ...
JTester's user avatar
  • 483
11 votes
11 answers
50k views

HTTP Error 500.0 - ASP.NET Core IIS hosting failure (in-process) in Dot net core 3.1

**I had checked all possible ways to Solve this error like installed dot net core 3.1 runtime environment set AspNetCoreHostingModel as OutProcess But still getting this error when i'm trying to set ...
Rinku Choudhary's user avatar
11 votes
3 answers
5k views

Run code after openid connect sign-in in Asp.net Core

I am trying to figure out the best way to run some code once a user has authenticated themselves using OpenID Connect on a Dotnet Core MVC App. I don't want to hard code a redirect URL after sign-in ...
Mitch Dart's user avatar
  • 1,341
10 votes
1 answer
8k views

'IConfigurationSection' does not contain a definition for 'Get' and no accessible extension

I created the JwtHelper class. I have been using it for a long time. However, when I updated the packages, I got an error in the following line; The complete error message is as follows; Severity ...
Fırat DİKMEN's user avatar
10 votes
1 answer
16k views

ASP.NET Core server side validation failure causes Microsoft.AspNetCore.Mvc.SerializableError

I use [EmailAddress] attribute to validate email on server side. However, when I send an invalid email address, I receive a 400 status code response with no message instead of getting into my action ...
Maksym Lapshyn's user avatar
10 votes
2 answers
8k views

Confusion: ASP.NET Core 2 is not managed code, but what is the ASP.Net Core Runtime for?

Regarding Microsoft documentation here in the IIS in the Apppool we can set "Not managed code" for our ASP.NET Core 2 App because the ASP.NET Core 2 app does not need a CLR: This is confusing to us ...
Simon's user avatar
  • 4,469
10 votes
5 answers
15k views

How to use @section scripts in a partial view MVC.Core

In ASP.NET Core MVC it is possible to define a script section for a page like this: @section scripts { <script> alert('hello'); </script> } And if the the layout contains ...
Ivan Valadares's user avatar
10 votes
6 answers
15k views

How convert IConfigurationRoot or IConfigurationSection to JObject/JSON

I have the following code in my Program.cs: var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("clientsettings....
heoLixfy's user avatar
  • 141
10 votes
2 answers
2k views

What is the ASP.NET Core equivalent of ViewData.TemplateInfo.GetFullHtmlFieldId("PropertyName")?

I'm migrating a web app to .NET Core, and it uses a few Razor editor templates for specific input types (e.g. outputting a date input for any DateTime model properties). A couple of the templates use ...
Mark Bell's user avatar
  • 29.3k
10 votes
2 answers
15k views

Web API Asp.Net 6 Routing Clarification

I am using Asp.net 6 web API in my project and I am confused about understanding routing functions. Previously when we build API we use to use following middleware app.UseRouting() ...Other ...
Haseeb Khan's user avatar
10 votes
2 answers
4k views

Activity based Authorization in ASP.NET Core

We have an asp.net mvc application which I'm porting to aspnet core mvc. In the old solution authentication is done using Windows authentication. On top of that we have an "activity based ...
mortb's user avatar
  • 9,580

1
2 3 4 5
22