-1

I have a .NET MVC application which also has a security module for login, in a different project (but the same solution). None of these were built by me. They already existed when I started working for my employer.

When I run the application from within Visual studio, I am able to log in normally. But when I deploy the application on IIS 7 (File system publishing) the website loads, but just displays a blank page with no errors when I try to log in (which means the deployed application probably can't access the security databases for login). I don't see any errors in my browser's developer tools console.

The default url http://localhost:85/UserAccount/Login shows the login screen. After entering my username and password, it just stays on the same url, but displays a blank page. When I run this from within visual studio, an unsuccessful login displays an error message while a successful login redirects me to http://localhost:85/UserAccount/Home

How do I resolve this?

doodles
  • 63
  • 3
  • 11

1 Answers1

0

Check to make sure that the security context running IIS has write permissions to where your logger is logging, and make sure your web.config file is set to logging = true (the method for this depends on which .NET MVC you are using). Default settings for both of these will cause IIS to show you a blank screen if you have an error, and since this works in VS, it is probably an environment problem (such as permissions). When I am running local on a machine in my work domain, I make the logging folder Writeable by Everyone, and make sure the following is in my web.config (note I am using ASP.NET Core with EntityFramework):

<?xml version="1.0" encoding="utf-8"?>
  <configuration>

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
 </configuration>

In the above example, logging is turned on and will go into a logs folder under the virtual application directory (which you must make sure exists and has write permissions for your IIS context). If you have an error, it will show up in that folder, and you will be able to debug it.

  • Thanks for the response! Just clarifying that the application is using .NET MVC 4 with .NET Framework 4.5. I found the following in the web.config file: But this does not seem to be writing any error logs even after I created the target folder. Any suggestions? – doodles May 22 '17 at 01:24
  • In short, I just need to know how to enable logging for MVC 4 with .NET 4.5, the way you have done for .NET Core. – doodles May 22 '17 at 02:40
  • I did have to enable logging in the web.config (using RDP). But this response is actually way faster for finding and fixing your deployment issues: https://stackoverflow.com/questions/41915522/asp-net-core-1-1-runs-fine-locally-but-when-publishing-to-azure-says-an-error-o – John Johansen Nov 05 '17 at 19:22