0

I am having horrible trouble debugging a MVC ASP.NET webpage deployed to IIS. The website works perfectly on localhost on the PC where it has been made. When I navigate to the page on a different PC on the same network however, I get this error :

https://i.stack.imgur.com/N359Q.png

Further inspection with Fiddler2 gives me the following information, the only debug information I can seem to get from this solution:

Fiddler2 info

Here is the Layout.cshtml :

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Intranet Page</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/Scripts/application.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("IntranetPage", "Index", "Home")</p>
                </div>
                <div class="float-right">
                 <!--   <section id="login">
                    </div>
                    <div id="logindisplay">
                        Context.User.Identity.Name <strong>@Context.User.Identity.Name</strong>!
                    </section>  This works correctly to get DOMAIN/USERNAME-->
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

And the index page in question :

@model IEnumerable<WhoIs.Models.Employee>
@{
    ViewBag.Title = "Contoso Employees";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
            </hgroup>
        </div>
    </section>
}

      <label for="filter">Enter employee details here : </label>
      <input type="text" name="filter" value="" id="filter" />

<h2><strong>Users</strong> (<a href="/home/create" style="color: blue;">create new</a>)</h2>
<br />

<div style="min-height: 150px; font-size: 1.25em">
    <div style="margin-bottom: .5em">
        <table><thead><tr><th>Name</th><th>Branch</th><th>Phone No.</th><th>Username</th><th>Email</th></tr></thead>
            <tbody>
            @foreach ( var prod in Model )
                {
                    <tr>
                        <td>@prod.FullName</td> 
                        <td>@prod.Branch</td> 
                        <td>@prod.PhoneNo</td> 
                        <td>@prod.DomainAC</td> 
                        <td>@prod.Email</td> 
                        @if (User.IsInRole(@"Admins") || User.Identity.Name == prod.DomainAC) {
                                <td><a href="/home/edit/@prod.Id"  style="color: blue;">edit</a></td>
                         }else{
                         <td>User => @User.ToString()</td>   
                        }
                    </tr>
                 }
                 </tbody>
            </table>
        </div>
     </div>

These render a simple page with a list of employees at Contoso, giving Admins and users themselves the ability to edit their details. Can anyone see what may be causing my problem here ? I have investigated this thoroughly with no results.

I have a .edmx file added to my models folder which is linked to the remote database Employees. I have tried to edit the web.config to give more information on what may be the problem by adding the lines :

But I am still only getting the error message above.

Can anyone tell me what may be causing this problem please ? Commenting out the section where I retrieve from the database gets rid of the error, but I cannot solve it.

Thanks a lot.

Edit :

Web.config extract :

<system.web>
    <compilation debug="true"/>
    <deployment retail="false" />
    <customErrors mode="Off">
    </customErrors>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>

    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx">
      <controls>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxx" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>
pnuts
  • 58,317
  • 11
  • 87
  • 139
Simon Kiely
  • 5,880
  • 28
  • 94
  • 180
  • You could disable the customErrors in your application deployed to IIS so you can see more details about the 500 error. See here: http://stackoverflow.com/questions/101693/customerrors-mode-off – ctrucza Jul 22 '13 at 09:30
  • Also: from the fiddler output you can see that the /Scripts/Application.js cannot be found (404). Probably ~/Scrips/Application.js would work. – ctrucza Jul 22 '13 at 09:32
  • Do you have anonymous authentication turned on on the other computer? If you use Windows Authentication to connect to the database, then the most common reason is that the account you are connecting as on another machine is the asp_net identity, which wont be permissioned for the required level of db access. – dash Jul 22 '13 at 09:37
  • @ctrucza I have tried everything within that question and unfortunately am still left with no reasonable error message. In my web.config I have simply put : " ". Thanks for the suggestion ! – Simon Kiely Jul 22 '13 at 09:37
  • Unexpected... Just an idea (from the same post): in machine.config do you have ? – ctrucza Jul 22 '13 at 09:40
  • @dash Anonymous authentication is enabled in my web.config file, however I am not sure what you mean when you say to enable it on the other machine? – Simon Kiely Jul 22 '13 at 10:25
  • @ctrucza My machine.config doesn't have a deployment element. – Simon Kiely Jul 22 '13 at 10:26
  • I mean you should try disabling anonymous authentication on the other machine just to see if it's a NT user context issue. – dash Jul 22 '13 at 10:31
  • @dash How can I do this? I didn't realise Windows had a setting to allow/disallow anonymous authentication; I thought this was just a setting in IIS. – Simon Kiely Jul 22 '13 at 10:34
  • Updated my code above to include the relevant extract from my web.config file. – Simon Kiely Jul 22 '13 at 10:37
  • It's available via IIS itself under the Authentication Methods section. See http://technet.microsoft.com/en-us/library/cc733010%28v=ws.10%29.aspx – dash Jul 22 '13 at 10:38
  • @dash Oh sorry, when you said "other machine" I thought you meant the client machine - I have already disabled anonymous authentication on the server machine and it will still work perfectly when I navigate to the site from the server machine, but not from any client. – Simon Kiely Jul 22 '13 at 10:42
  • @ctrucza Sorry, edited the machine.config file now to have deployment retail="false". Unfortunately still the same error message.ress concerns raised. – Simon Kiely Jul 22 '13 at 11:46

1 Answers1

0

I had similar problem, and there are a lot of pitfalls I came across. I will try to provide their full list to help you check them:

  • allow Directory browsing in your IIS
  • in the folder, where the website is physically saved, check whether IUSR and IIS_IUSR have the permissions to read and browse
  • check, whether you have allowed accessing the port in your firewall
  • check, whether the IP address is correct. It is possible, that your external IP does not redirect to the internal IP. Or maybe (I made the rookie mistake) you are trying to browse the internal IP instead of external.

I hope this will help. If any questions, do not be afraid to ask.

Storm
  • 3,062
  • 4
  • 23
  • 54
  • Thanks for the response. Unfortunately, I have verified all these settings to be correct and the problem persists. – Simon Kiely Jul 22 '13 at 11:50
  • Ah this lead me to my solution, thank you. I ended up applying all of the settings you suggested, restarting IIS. Nothing. Deleted my machine.config file, saved a new version, stopped IIS, restarted my PC, restarted IIS, saved the new version of machine.config into the relevant config folder (using Visual Studio 12 running as an administrator) and I have now retrieved an error message. Finally. Thank you ! :) – Simon Kiely Jul 22 '13 at 12:07