Nauman
Nauman

Reputation: 218

This page isn’t working .Localhost is currently unable to handle this request. HTTP ERROR 500

This page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

I have published Web API project on IIS with all configurations.

Already tried things:

  1. .Net Core hosting bundle. (added) and I can see it in IIS target website modules.
  2. IIS settings checked many times.

Note:

  1. API URL is just returning a method which have string return type which is But when I hit another method which have list return type it shows the message "localhost is currently unable to handle this request".

  2. Without publishing project on IIS it is working perfectly fine.

Default methods controller are working perfectly fine which returns string.

But when I call other methods in the controller it shows error message "Localhost is currently unable to handle the request" *URL not working (calling default method which returns string)

enter image description here

working URL (calling another method in controller)

enter image description here

Upvotes: 5

Views: 25572

Answers (3)

Prince
Prince

Reputation: 163

Make sure this part comes on top in your Configure method in Startup file

if (env.IsDevelopment())
   {
     app.UseDeveloperExceptionPage();
     app.UseSwagger();
     app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "learning_todo_jwt v1"));
   }

Upvotes: 2

Nauman
Nauman

Reputation: 218

1- enable app.UseDeveloperExceptionPage(); in startup.cs file. Now execption will show in broweser instead of "Localhost is currently unable to handle the request"

Issue was with the connection string after adding userid and password in connection string my issue resolved. Thanks for your help and guidance.

Upvotes: 11

Gabriel Luci
Gabriel Luci

Reputation: 40938

If the error code you get is just 500, not 500.x, then this describes what's going on:

The app starts, but an error prevents the server from fulfilling the request.

This error occurs within the app's code during startup or while creating a response. The response may contain no content, or the response may appear as a 500 Internal Server Error in the browser. The Application Event Log usually states that the app started normally. From the server's perspective, that's correct. The app did start, but it can't generate a valid response. Run the app at a command prompt on the server or enable the ASP.NET Core Module stdout log to troubleshoot the problem.

So you need to figure out what went wrong in your app.

There are more troubleshooting steps under the Troubleshoot on IIS section. In my experience, the most useful troubleshooting step is enabling the stdout log in web.config.

<aspNetCore processPath="bin\myapp.exe" stdoutLogEnabled="true" stdoutLogFile=".\stdout" />

That should hopefully show you an error message in that file and you can search for that error.

Upvotes: 0

Related Questions