ASP.NET Core MVC causes 500 error on IIS 8.5


Mickey

Using .NET Core 3.1, I developed an MVC application and deployed it on IIS 8.5.

Using a browser, I can go to the home page when I visit, domain.com/myApp/but I get an http 500 error when I visit domain.com/myApp. This is working locally. The problem occurs on deployed servers.

This is my route in Startup.cs

app.UseEndpoints(endpoints =>
{
    // localization
    endpoints.MapControllerRoute(
        name: "LocalizedDefault",
        pattern: "{language:language}/{controller}/{action}/{id?}");

        endpoints.MapControllerRoute(
        name: "default",
        pattern: "{*catchall}",
        defaults: new { controller = "Home", action = "RedirectToDefaultCulture", language = "en" });
        });

I inserted some log statements in the RedirectToDefaultCultureaction method . Doesn't seem to hit home controller when there is no / at the end of the URL

I have developer exceptions enabled but it doesn't show me the error

I also tried providing default values LocalizedDefault​​for routes with no luck .

I successfully loaded the home page domain.com/myApp/Index(without the forward slash at the end)

Shouldn't the default endpoint capture the route?

Mickey

The answer turned to me.

I'm injecting RequestLocalizationOptionsin the configure method , startup.csbut there is a final code at the end where class RouteDataRequestCultureProvider : RequestCultureProviderI expect the url :/

string twoLetterCultureName = string.Empty;
if (httpContext.Request.Path.Value.EndsWith('/'))
{
    twoLetterCultureName = httpContext.Request.Path.Value.Split('/')[IndexOfCulture]?.ToString();
}
else
{
    if (httpContext.Request.Path.Value.Contains("en")) twoLetterCultureName = "en";
    else twoLetterCultureName = "fr";
}

I feel so bad!

Thanks everyone for helping me solve this bug

Related


ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

Deploying ASP.NET Core API to local IIS error 500

Michael Reno Platama Setavan I have a problem with my application after deploying to local IIS. I've made an API using ASP.NET Core and have run it on Visual Studio and it works. It can perform GET, POST, PUT and DELETE requests. Then I want to deploy it to lo

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

Brandon I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server erro

Deploying ASP.NET Core API to local IIS error 500

Michael Reno Platama Setavan I have a problem with my application after deploying to local IIS. I've made an API using ASP.NET Core and have run it on Visual Studio and it works. It can perform GET, POST, PUT and DELETE requests. Then I want to deploy it to lo

Deploying ASP.NET Core API to local IIS error 500

Michael Reno Platama Setavan I have a problem with my application after deploying to local IIS. I've made an API using ASP.NET Core and have run it on Visual Studio and it works. It can perform GET, POST, PUT and DELETE requests. Then I want to deploy it to lo

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

ASP.NET Core WebAPI 500 Internal Error in IIS 7.5

james I am trying to get this WebAPI to work. Well, use IIS. Everything works fine in IIS express, but when I publish it, especially 1 api request doesn't work. The url I am trying to access API/[Controller]/{date}/{integer}. I keep getting a 500 server error.

Deploying ASP.NET Core API to local IIS error 500

Michael Reno Platama Setavan I have a problem with my application after deploying to local IIS. I've made an API using ASP.NET Core and have run it on Visual Studio and it works. It can perform GET, POST, PUT and DELETE requests. Then I want to deploy it to lo

Deploying ASP.NET Core API to local IIS error 500

Michael Reno Platama Setavan I have a problem with my application after deploying to local IIS. I've made an API using ASP.NET Core and have run it on Visual Studio and it works. It can perform GET, POST, PUT and DELETE requests. Then I want to deploy it to lo

Running ASP.NET 5 (MVC 6) with .NET Core on IIS

Ash I just created a snappy ASP.NET 5 MVC 6 application on Visual Studio.NET 2015 RC, hoping it will run on Windows 7's IIS web server. Usually, when I create a website on IIS, I need to choose an application pool of v2.0 or v4.0 Integrated. Now, since all the

Running ASP.NET 5 (MVC 6) with .NET Core on IIS

Ash I just created a snappy ASP.NET 5 MVC 6 application on Visual Studio.NET 2015 RC, hoping it will run on Windows 7's IIS web server. Usually, when I create a website on IIS, I need to choose an application pool of v2.0 or v4.0 Integrated. Now, since all the

Running ASP.NET 5 (MVC 6) with .NET Core on IIS

Ash I just created a snappy ASP.NET 5 MVC 6 application on Visual Studio.NET 2015 RC, hoping it will run on Windows 7's IIS web server. Usually, when I create a website on IIS, I need to choose an application pool of v2.0 or v4.0 Integrated. Now, since all the

Running ASP.NET 5 (MVC 6) with .NET Core on IIS

Ash I just created a snappy ASP.NET 5 MVC 6 application on Visual Studio.NET 2015 RC, hoping it will run on Windows 7's IIS web server. Usually, when I create a website on IIS, I need to choose an application pool of v2.0 or v4.0 Integrated. Now, since all the

Running ASP.NET 5 (MVC 6) with .NET Core on IIS

Ash I just created a snappy ASP.NET 5 MVC 6 application on Visual Studio.NET 2015 RC, hoping it will run on Windows 7's IIS web server. Usually, when I create a website on IIS, I need to choose an application pool of v2.0 or v4.0 Integrated. Now, since all the

HTTP 500 error with ASP.NET Core application on IIS Express 10

Numirani I believe I have narrowed it down to a misconfiguration, but I can't find where the error lies. Steps to reproduce: Created a new project in Jetbrains Rider 2020.3. ASP.NET Core web application, Windows Authentication. Let the new project build itself

500 error when deploying asp.net core web api to IIS 7.5

username I have an asp.net core web API project that I am trying to host in IIS 7.5. As suggested in the following article, Could not find configuration file 'appsettings.json', it is not optional Below is my "appsettings.json" file, { "ConnectionStrings": {

ASP.NET 5 IIS 500 error with EF7 application

Rays I have an application hosted in IIS 8, developed in ASP.NET 5, MVC 6 and EF7. I've created an API for the app to be accessible via and http://localhost/apialso created some controllers to access the data. When I access the API from Visual Studio everythin

ASP.NET 5 IIS 500 error with EF7 application

Rays I have an application hosted in IIS 8, developed in ASP.NET 5, MVC 6 and EF7. I've created an API for the app to be accessible via and http://localhost/apialso created some controllers to access the data. When I access the API from Visual Studio everythin

ASP.NET 5 IIS 500 error with EF7 application

Rays I have an application hosted in IIS 8, developed in ASP.NET 5, MVC 6 and EF7. I've created an API for the app to be accessible via and http://localhost/apialso created some controllers to access the data. When I access the API from Visual Studio everythin