0

I have published my .net core 7 web application using visual studio 2022 and IIS-10 to my local folder in "inetpub\wwwroot\iddcsw". enter image description here I have fully tested my application before publishing them and it's working fine but after published to a local folder and ran my application, I encountered this server request error from my ajax call and doesn't provide any actual error/exception messages. enter image description here I have also check the folder in "FailedReqLogFiles" but nothing is there, no logs at all. When I checked the httperr1 file from the LogFiles folder in system32. I got this enter image description here What does this mean? and how to fix this? Any solution for this HTTP Error 500 on my end? If you know the solution, please let me know. Thank you.

timmack
  • 590
  • 2
  • 12
  • 43
  • An ASP.NET Core web app cannot be deployed to any folder. You have to create a site or application on IIS, https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis and then publish the contents there. Depending on the actual ASP.NET Core app type you use, there might be extra steps. Escalate to your team mates or hire a consultant to learn more. – Lex Li Jan 15 '23 at 20:10
  • @LexLi ok, I guess I don't need the folder so I should just have to deploy my application directly to my site created in IIS. But how about the format on my ajax url server request? Should it be like this http://myIP/Controller/Action/{id} something like that? Pls elaborate. – timmack Jan 16 '23 at 01:26
  • @LexLi just a follow-up though, you said An ASP.NET Core web app cannot be deployed to any folder. You have to create a site or application on IIS, but when you create a site in IIS it would require a content directory with a physical path, right? should I just target the path in wwwroot folder? if we won't create a new folder? – timmack Jan 16 '23 at 02:16
  • Yes, it requires a content directory with a physical path when you create a site. And wwwroot is simply there as the container for the default website for the server. You could use wwwroot as the path or create a folder yourself. – TengFeiXie Jan 16 '23 at 02:28
  • 1
    Also, you can refer to [Publish an ASP.NET Core app to IIS](https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-7.0&tabs=visual-studio). Http 500 error have many causes. [HTTP Error 500.0](https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/www-administration-management/http-error-500-when-you-visit-web-site). After you deploy the web application to the site. The url format should be like this http(s)://:/? – TengFeiXie Jan 16 '23 at 09:45
  • @TengFeiXie...I suspect that this problem occurs because the ISAPIModule module is missing from the modules list from my Web site in my IIS. And also in my IIS10, I don't have the option to Add the ISAPIModule module to the modules list in my Web site. Why is that? – timmack Jan 16 '23 at 11:35
  • If there is no ISAPIModule in IIS, just search for ISAPI via Web Platform Installer. About Setting up ISAPI on IIS 10, you can refer to [this tutorial](https://www.softwareverify.com/blog/setting-up-isapi-on-iis-10/). – TengFeiXie Jan 17 '23 at 09:44
  • still no luck, this local machine deployment using IIS is much harder than deploying the application to the remote host server. – timmack Jan 17 '23 at 11:05
  • @TengFeiXie...after adding ISAPIModule module in my IIS 10. The ajax request with this format http://:/? would still throw an http error 500 but the actual error can't be previewed in the network console. Any thoughts? – timmack Jan 18 '23 at 02:32
  • Do I still missed any IIS configuration? – timmack Jan 18 '23 at 02:33
  • I see that your application is deployed on C drive. Insufficient permissions will also cause 500 error. You can try granting IIS_Users full control permissions. Detailed steps refer to [this answer](https://stackoverflow.com/questions/14934006/iis-iusrs-and-iusr-permissions-in-iis8). – TengFeiXie Jan 19 '23 at 09:43
  • @TengFeiXie...this has been done as well before I deployed it in a local windows 10 machine but still got that http 500 error when the ajax request is triggered. Have you tried doing this in a windows 10 machine? – timmack Jan 21 '23 at 08:31
  • Do I still need to setup my connection string inside IIS? – timmack Jan 22 '23 at 07:19
  • I think we can go back to the original question. Find the cause of the 500 error. If the official documentation on 500 error does not cover your situation. Using FRT to generate logs is still the best way. Regarding IIS not generating logs, I have encountered the same problem. [This answer](https://superuser.com/questions/1619876/iis-failed-request-tracing-not-working) worked for me. Logs can help you narrow down the problem in more detail. – TengFeiXie Jan 31 '23 at 09:44
  • 500 error is a common error. I also encountered it when deploying in IIS. When it has error code it is easier to define the cause. Generating a log file is the best way to go when the browser doesn't give any error code. – TengFeiXie Feb 01 '23 at 09:56
  • @TengFeiXie - This is the actual error in the log file after published to IIS "System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "MyDB" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\SYSTEM'." – timmack Feb 25 '23 at 10:11
  • Do I still need to add a connection string in the IIS under Connection Strings after being published? – timmack Feb 25 '23 at 12:22

0 Answers0