NetworkError: 500 Internal Server Error

Discussion in 'Windows / IIS' started by oposvrupert, Dec 4, 2011.

  1. Hello

    I built this site using VS MVC3.
    http://www.oposvrupert.com/

    I use IIS with integrated mode.

    I have separated users on 2 types: normal user who can look at my pages and Administrator, for editing various data. Admin pages are protected using Forms Authentication.

    Web page actually loads(html) but external css doesnt load:
    NetworkError: 500 Internal Server Error - http://www.oposvrupert.com/myStyles/Site.css

    There are no more (detailed) messages about this bug. Pleas help how to fix this.

    using this code in web.config:
    In attachment(txt)

    Any help is appreciated.
     

    Attached Files:

  2. Error displays on every access to (external) script (js), style(css) and images (png).

    I forgot to mention that this Site (and whole App) works normally in local IIS and in VS debug mode, and doesn't report any errors.
    Any ideas?
     
  3. web.config problem?

    Discount ASP.Net support team has been very helpful in providing me help.
    Problem is in Web.config file :
    I have tried everything I could and no success. In attchment is my Web.config file.

    Application is written in VS MVC3.

    <configuration>
    <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>
    <system.web>
    <identity impersonate="false"/>
    <authentication mode="Forms">
    <forms loginUrl="~/Account/Login" defaultUrl="/Home/Index" timeout="4500">
    </forms>
    </authentication>
    <authorization>
    <allow users="*"/>
    </authorization>
    <customErrors mode="Off"></customErrors>
    <compilation debug="false" targetFramework="4.0">
    <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </assemblies>
    </compilation>
    <pages validateRequest="false" >
    <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages"/>
    </namespaces>
    </pages>
    </system.web>
    <location path="Admin">
    <system.web>
    <authorization>
    <deny users="?" />
    </authorization>
    </system.web>
    </location>
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="false"/>
    <staticContent>
    <mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
    </staticContent>
    <httpErrors errorMode="Detailed"/>
    <asp scriptErrorSentToBrowser="true"/>
    </system.webServer>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>
     

    Attached Files:

  4. I'm taking a look at at your site but I see you're currently working on it, as the error changed.

    The 500 error usually means there's an error with the web.config, but I would recommend enabling Failed Request Tracing on your account to better log these sorts of errors.
     
  5. solved the problem without forms auth and using session

    I still don't know what the problem was.
    Anyway I disabled Forms Authenitacation and I have on "preinit" load in MVC implemented this:

    Code:
    protected override void OnActionExecuting(ActionExecutingContext ctx)
            {
                base.OnActionExecuting(ctx);
    
                if (!Helper.IsAdminLoggedIn())
                {
                    ctx.Result = new RedirectToRouteResult(
                    new RouteValueDictionary(
                        new
                        {
                            controller = "Login",
                            action = "Index"
                        }));
                }
            }
            public const string adminCheckSessionKey = "adminCheckSessionKey ";
    
            public static bool IsAdminLoggedIn()
            {
                return (HttpContext.Current.Session[m_adminCheckSessionKey ] != null);
            }
    
            public static void SetAsAdminLoggedIn()
            {
                HttpContext.Current.Session[adminCheckSessionKey] = adminCheckSessionKey;
            }
    
            public static void SetAsAdminLoggedOut()
            {
                HttpContext.Current.Session.Remove(adminCheckSessionKey);
            }
    and that works a charm.

    i have saved administators in web.config file

    in my LoginController:

    Code:
     public ActionResult Index()
            {
                return View("Index", new AdminUser());
            }
    
            [HttpPost]
            public ActionResult check_admin_pwd(AdminUser _adminUser)
            {
                string form_password = _adminUser.password;   
    
                if (form_password.Equals(System.Configuration.ConfigurationManager.AppSettings.Get([I]admin_list[/I])))
                {
                    Helper.SetAsAdminLoggedIn();
                    return RedirectToAction("news_list", "Admin");
                }
                else
                {
                    return View("Index", new AdminUser());
                }
            }
    
            public ActionResult Logout()
            {
                Helper.SetAsAdminLoggedOut();
                return RedirectToAction("Index", "Home");
            }
    
    problem solved and without forms auth.
     

Share This Page