Last post Dec 20, 2018 08:05 AM by Wei Zhang
Dec 14, 2018 07:06 PM|CSpace|LINK
I have a site in IIS 10 who's default document is configured to be default.aspx.
When I goto site/ (or http://site) in browser, I get object reference not set to an instance of an object and can see the line of code.
If instead I goto site/default.aspx (or http://site/default.aspx), it runs fine without error.
I can't seem to find a reason for the differrence in behaviour (the fact that an unhandled exception is thrown) nor a reason for the error as the code is good and runs
fine in Visual Studio debug mode.
the code is a simple if/then: If UserName.ToUpper <> "WHATEVER" then
runs fine in VS, runs fine as http://site/default.aspx but errors when calling
http://site and default.aspx is the default document in IIS 10.
Can you suggest something i can check on?
Dec 17, 2018 08:37 AM|Wei Zhang|LINK
According to your description,I suggest you to check the default document in your WebSite in IIS manager.If the default Document is not default.aspx, that may leads to the error.
Else, if not the error in default Document, could you please post the detail about the UserName? I am looking forward to your reply.
Dec 17, 2018 01:47 PM|CSpace|LINK
Hi and thanks for your reply.
The default document in IIS is default.aspx.
UserName = Request.ServerVariables("LOGON_USER")
UserName = Replace(UserName, "MYDOMAIN\", "", 1, Len(UserName), CompareMethod.Text)
If UserName.ToUpper <> "WHATEVER" then '<<<ERROR IS ON THIS LINE <<<<
...some code here....
The strange thing about this is when the URL contains the page name (http://site/default.aspx) it runs fine, without it (http://site), the error is thrown.
Also runs fine in VS.
Dec 20, 2018 08:05 AM|Wei Zhang|LINK
According to the code you posted, I have made a sample on my side. However it still works well.
Try to remote debug on a remoteIIS Computer.Here is the link,I hope it can help you.