All Questions
Tagged with .net-core asp.net-mvc
1,060
questions
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 ...
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
...
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 ...
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-...
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 -...
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.
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 ...
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; ...
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 ...
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, ...
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 ...
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 (...
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 ...
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#
|
...
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 ...
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": {
...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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.
...
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)
{
...
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 ...
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....
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] ...
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 ...
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 ...
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 ...
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....
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" --...
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("...
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 = ...
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 ...
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-...
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 ...
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 ...
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/...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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 ...