HTTP Error 503, the service is unavailable Azure Virtual machine - asp.net

I have created one Azure Virtual machine and installed all the IIS related roles and features.
After that I have created one Website in IIS.
I have given all the needed permissions to "Physical Path" and also configures https bindings.
The website gives "HTTP Error 503, the service is unavailable" error after few requests and responses are made on the website.
What could be the problem here? The Website works fine until any request-responses are made.

Check the event viewer, there must be an exception caught from the application. Resolve and check it must be working.

Related

Can't get simple Azure AD ASP.NET authenticated web app to work

I have used the Visual Studio template for an ASP.NET Webforms app with Azure AD authentication to create a simple web app. It works 100% fine locally. I can sign in, sign out, all good. Whenever I deploy to either AWS or Azure however, the behavior changes. The sign in still comes up fine, no issues at all, but after signing in, instead of taking me to the site, the browser just thinks for ages before dumping me to this error in the browser:
Server Error in '/' Application.
Runtime Error Description: An application error occurred on the
server. The current custom error settings for this application prevent
the details of the application error from being viewed remotely (for
security reasons). It could, however, be viewed by browsers running on
the local server machine.
Details: To enable the details of this specific error message to be
viewable on remote machines, please create a tag within
a "web.config" configuration file located in the root directory of the
current web application. This tag should then have its
"mode" attribute set to "Off".
I have tried adding the web.config setting and redeploying and it makes zero difference. Because I'm using App service on Azure for instance, I can't run the site on the actual web server as I don't have access to it. I tried looking at diagnostic log streaming, and got the below? Please help? Anyone? I have no idea why this isn't working. Interestingly, although I have asked that the site be http and it runs locally as http, once uploaded the url becomes https. Not sure if that' related.
From streaming logs (Azure)
HTTP Error 500.0 - Internal Server Error The page cannot
be displayed because an internal server error has occurred.
Most likely
causes: IIS received the request; however, an internal
error occurred during the processing of the request. The root cause of
this error depends on which module handles the request and what was
happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site
or application. This can occur if the NTFS permissions are set
incorrectly. IIS was not able to process configuration for
the Web site or application. The authenticated user does not
have permission to use this DLL. The request is mapped to a
managed handler but the .NET Extensibility Feature is not
installed. Things you can try:
Ensure that the NTFS permissions for the web.config file are
correct and allow access to the Web server's machine account.
Check the event logs to see if any additional information was
logged. Verify the permissions for the DLL.
Install the .NET Extensibility feature if the request is mapped
to a managed handler. Create a tracing rule to track failed
requests for this HTTP status code. For more information about
creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module __DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule,
Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35_79846f5c-7e22-4a97-8a1c-24bc400cf7db
Notification EndRequest
Handler ExtensionlessUrlHandler-Integrated-4.0
Error Code 0x00000000
Requested
URL https://SimpleADApp:80/
Physical
Path D:\home\site\wwwroot Logon Method Not yet
determined Logon User Not
yet determined
More Information: This error means that there was
a problem while processing the request. The request was received by
the Web server, but during processing a fatal error occurred, causing
the 500 error. View
more information ยป Microsoft Knowledge Base
Articles:

ASP.Net / AppFabric causes 4011 error "An unhandled access exception has occurred."

I am deploying a version of my website which I have developed AppFabric integration into, instead of using the ASP.NET Memory Cache (we're going to load balance a few web servers, so need distributed caching as opposed to local RAM caching).
Locally, I have AppFabric 1.1 installed, and my website communicates with it over 'localhost' (AppFabric installed on the same computer as the website runs out).
<dataCacheClient>
<hosts>
<host name="localhost" cachePort="22233" />
</hosts>
<securityProperties mode="None" protectionLevel="None" />
</dataCacheClient>
When I deploy this site to one of the test servers in our hosting environment (with AppFabric 1.1 also installed locally on that server), the site in IIS immediately fails, in under one second. If I stop IIS and then start it again, and then refresh the page locally, I get the IIS generic "HTTP Error 500.0 - Internal Server Error" in 800ms. This surprised me - I thought the site would be spinning up ASP.NET stuff and not actually running "user code" in that quick of a time.
So all the site's data access has changed to the pattern of, "check AppFabric for object, if it doesn't exist, retrieve from DB & store inside AppFabric" - so it seems
If I deploy a version of the site to the exact same folder, with all of the AppFabric caching changed to use the in-memory ASP.NET cache, then the site loads with no issues, so the problem is 100% related to AppFabric.
There is no exception logged, I simply see the generic "HTTP 500.0 Internal Server Error" message. If I check the Event Viewer then I can see an exception logged:
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 01/12/2017 12:37:19
Event time (UTC): 01/12/2017 12:37:19
Event ID: 84321f68413340daaf0badf122ceed87
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT-3-131566054392620836
Trust level: Full
Application Virtual Path: /
Application Path: ..\..\..\..httpdocs-shared-cache\
Machine name: machine
Process information:
Process ID: 26752
Process name: w3wp.exe
Account name: -
Request information:
Request URL: https://localhost:443/Index.aspx
Request path: /Index.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: -
Custom event details:
There is no stacktrace to show WHERE the failure is occurring.
I have configured AppFabric's security like this (as a test) - and as shown in the web.config, we talk to AppFabric with 'None' for both security mode & protection level.
Set-CacheClusterSecurity -SecurityMode None -ProtectionLevel None
I have hit a brick wall with this and am not sure where else to turn. I tried to install AppFabric 1.0 on the server but it is no longer supported on Windows 2016.
Locally I am using AppFabric 1.1 and am running on Windows 10. As stated, if I deploy the exact same codebase, just with AppFabric communication replaces with .NET memory cache then the site loads okay on the server, which is why I'm convinced it's related to AppFabric.
Does anyone have any pointers as to where I can start to look into this further? I tried
Turns out, ELMAH was catching the exception and still creating the XML log file. This pointed me towards 'Access to the 'global' registry key is denied' - you have to add the application pool user to the 'performance log' and 'performance monitor' user groups.

IIS Error HTTP Error 401.3 - Unauthorized Windows Server 2012 R2

I have website setup in IIS manager, when I select to view Browse the website, I get the follwoing error: HTTP Error 401.3 - Unauthorized ...You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
I've confirmed that I have full admin rights on the remote computer; In addition, I added IIS_IUSRS and applied full control / admin rights. However, still, I get the related Error: HTTP Error 401.3 - Unauthorized. I did notice that the "Permissions" for myself all have checks: Full control ...etc that our dimmed, but for IIS_IUSRS, the checks are bold; so am not sure if that makes a difference.
If I could gets some guidance as to what I may be doing wrong or if there is something else I need to look into in resolving the error, any suggestions our welcomed.

Access network file from ASP.NET web handler's process?

I have the following setup:
IIS 8.0
a web handler call it test.ashx
Impersonation & Windows Authentication are both configured. Kerberos is showing as the authentication type.
test.ashx uses the unmanaged API: CreateProcessAsUser() method to run "cmd.exe /c myScript.cmd"
I put statements in myScript.cmd and see that it is running as the requesting user as I need it to. The problem I am experiencing is that the script cannot reference network files (either mapped drives or UNC path)
I need myScript.cmd to run as the requesting user and to be able to access network file resources. How do I get this to work?
I found one item that made a big difference on getting kerberos authentication to work, which is required to do impersonation and delegation. In IIS Manager I had to choose the web site, then run the Configuration Editor. Once it opened I had to choose the as from: DefaultWebSiteWeb.Config, and as the section: system.webServer/security/authentication/windowsAuthentication. Then set: useAppPoolCredentials = True. Note: useKernelMode was already set to true.
Additionally, for the web site I have the following set for Authentication:
ASP.NET: Enabled
Windows Authentication: Enabled, Provider: Negotiate, Kernel mode enabled.
Now my ASHX web handler (in C#) can start a process as the user, run a .cmd file that accesses network resources.

ELMAH File Not Accessible on Local Machine using Host Name

I can access the elmah.axd file, to view errors, when browsing using the localhost host name (i.e. http://localhost:24425/admin/elmah.axd).
I created a different host name and added it in my host file (to mirror production domain name). When I browse the site, and force an exception, the exception does get logged (SQL Server) using the prod host name. However, I am not able to view the elmah.axd file (i.e. http://www.foo.com/admin/elmah.axd). I get "HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
When I force an exception, using the localhost url, the exception still does get logged in SQL and I am able to browse this file: http://localhost:24425/admin/elmah.axd. However, I only see exceptions that occur under the localhost url (not the www.foo.com url).
After reviewing SQL, I see errors that happen using localhost with Application "/" and User set to the account I am logged in with. The errors generated when using www.foo.com have Application set to "/LM/W3SVC/6/ROOT" and the User column is blank.
I just need to be able to access the elmah.axd file when using www.foo.com/admin/elmah.axd. I have set security allowRemoteAccess to "1" in my web.config and have also added the elmah stuff to system.web and system.webServer nodes in my web.config.
I am using Windows Server 2008R2, IIS7.5 and it is a ASP.NET site (set up as a Web Application).
Thanks for any advice given.
By default elmah.axd can only be viewed on the local machine (whicj is why using localhost works).
You need to configure the web application to allow remote access.

Resources