ASP.NET MVC 2 & IIS : HTTP 500.24 favicon.ico Error - iis

I have a little weird behavior with my ASP.NET MVC 2 application.
I'm using IIS 7.5, Windows Authentication and ASP.NET Impersonation for my webpage to load.
After several searches, I didn't found a nice way to get rid of the 500.24 Request that I keep getting on every page load (The favicon.ico at the root directory triggers this) :
I've looked at some articles like this one or that one but this doesn't seems to solve my issue. I need these settings on for my application to work here : .NET 4 Framework Integrated Mode pipeline, Windows Authentification and ASP.NET Impersonation.
Here's a simplified version of my web.config, if it can help anyone (of course, I've removed the connections strings for security reasons..)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<identity impersonate="true" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.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=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Windows">
<!-- roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" / -->
<!-- forms loginUrl="~/Account/LogOn" timeout="2880" / -->
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/Globe" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/Globe" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<security>
<requestFiltering>
<verbs>
<add verb="PUT" allowed="true" />
<add verb="DELETE" allowed="true" />
</verbs>
</requestFiltering>
</security>
</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" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
My application IS working, the favicon.ico IS loading, I'm just wondering why it does fires a 500.24 on every request (Of course, maybe it's Fiddler who can't authenticate itself and causes de 500.24 HTTP Error, but when it does normally it triggers a 401.2 - Unauthorized instead...)

My guess is that favicon.ico is either running in a different application pool, or there is a web.config in the root of the site that has issues.
So:
1) Check to see if the root of the site (the directory where /favicon.ico lives) includes a web.config. If it does, then check to see if it is setting a system.web/httpModule, or httpHandler, or system.web/identity (impersonate) or something like that, and the application pool is running in integrated mode.
So what you need to do is either remove the offending httpmodule/httphandler/impersonate setting, or change the application pool to run as classic, or add the same configuration your site includes which is <validation validateIntegratedModeConfiguration="false" />

What CarlosAg said. Cheap fix might be to move the favicon into the offended app rather than barking up the tree.

I did find the answer to my problem =)
You're gonna laugh at me, for sure.. =P
Well, part of the answer is the <validation validateIntegratedModeConfiguration="false" /> in the C:\inetpub\wwwroot that CarlosAg pointed out, but the other part was that I simply forgot to add the <link rel="icon" href="<%: Url.Content("~/favicon.ico")%>" type="image/x-icon" /> to my Site.Master file in my ASP.NET MVC 2 Application. Since Chrome and IE does look at the root directory for a favicon.ico, it appeared to work, but I didn't notice until now that Firefox wasn't loading up the favicon.
Now the favicon loads on every browser, and there is no 500.24 HTTP Request sent over in Fiddler.
Thanks ! =)

Related

ServiceStack Razor not rendering pages correctly after upgrade to 4.x

After upgrading the ServiceStack libraries on my website from 3.9.71 to 4.0.33, I noticed that ServiceStack.Razor is no longer rendering pages correctly. It appears to not be reading the layout.cshtml file. The pages load without the layout and without an error or warning. I've tried putting the layout.cshtml file in /Views/_layout.cshtml and /Views/Shared/_layout.cshtml.
In addition to replacing the packages during the upgrade, I also made the necessary changes to the Web.config file. Here is a snippet from my Web.config file. Please let me know if this is helpful or if I need to provide other information. Any help would be appreciated.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="webPages:Enabled" value="false" />
<add key="servicestack:license" value="{LICENSE_KEY_HERE}" />
</appSettings>
<system.webServer>
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<modules>
<add name="RightsModule" type="UI.security.RightsHttpModule" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.google.com" />
</conditions>
<action type="Redirect" url="http://google.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Required for MONO -->
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="1048576" />
<httpModules>
<add name="RightsModule" type="UI.security.RightsHttpModule" />
<add name="Airbrake" type="SharpBrake.NotifierHttpModule, SharpBrake" />
</httpModules>
<httpHandlers>
<!-- razor -->
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
<remove path="*.asmx" verb="*" />
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" />
<compilation targetFramework="4.5.1" debug="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<!-- add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/ -->
</assemblies>
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<authentication mode="Forms">
<forms loginUrl="/optimize/login.cshtml" protection="All" timeout="1440" name="AudiencePoint" path="/app" requireSSL="false" slidingExpiration="true" defaultUrl="/optimize" cookieless="UseCookies" enableCrossAppRedirects="false" />
</authentication>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="UI" />
<add namespace="System" />
<add namespace="ServiceStack" />
</namespaces>
</pages>
</system.web.webPages.razor>
<location path="optimize">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
</configuration>
Looks like the issue was that my code used the ServiceStack.Service.GetSession() method instead of the ServiceStack.Service.SessionAs() method to retrieve the UserSession. Not sure why this worked in 3.9.x but after I changed it, it started rendering in 4.0.x.
For the difference between the two methods checkout this stackoverflow question. They can't be used interchangeably.

elmah.axd not found on IIS 8.0

Ok..I know this is asked many times and I looked bunch of questions and answers about this and nothing worked for me and I am getting crazy. I am trying to put elmah to my asp.net mvc 5 application and I can't get it to work. I keep getting not found error.
My config for elmah is:
<appSettings>
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="false" />
<add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
<add key="elmah.mvc.allowedRoles" value="*" />
<add key="elmah.mvc.allowedUsers" value="*" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
<system.web>
<customErrors mode="On"></customErrors>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<!--<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />-->
</modules>
</system.webServer>
<elmah>
<security allowRemoteAccess="1" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/elmah" />
</elmah>
and yes i have ignored .axd in my rout config..
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
What am I missing ??
You need to create a MIME type for that extension in IIS:
To define a MIME type for a specific extension, follow these steps:
Open the IIS Microsoft Management Console (MMC), right-click the local computer name, and then click Properties.
Click HTTP Headers.
Click MIME Types.
Click New.
In the Extension box, type the file name extension that you want (for example, .axed)
In the MIME Type box, type application/octet-stream.
Apply the new settings. Note that you must restart the World Wide Web Publishing Service or wait for the worker process to recycle for the changes to take effect. In this example, IIS now serves files with the .axed extension.

sietmap.xml inaccessible in a site created with orchard. How to fix it?

I just published a website that I created using orchard cms. I added sitemap.xml to the root folder but can't access it via browser.
I am guessing that I probably need to modify web.config file but I am not sure how.
EDIT:
Here is my webconfig. I don't know how to format it properly here. I am accessing sitemap.xml at woodworkingoc.com/sitemap.xml but get 404.
<?xml version="1.0" encoding="utf-8"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="log4net.Config" value="Config\log4net.config" />
</appSettings>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
<namespaces>
<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" />
<add namespace="System.Linq" />
<add namespace="System.Collections.Generic" />
<add namespace="Orchard.Mvc.Html" />
</namespaces>
</pages>
</system.web.webPages.razor>
<!--
Set default transaction timeout to 30 minutes so that interactive debugging
is easier (default timeout is less than one minute)
-->
<system.transactions>
<defaultSettings timeout="00:30:00" />
</system.transactions>
<system.web>
<!--<trust level="Medium" originUrl="" />-->
<httpRuntime requestValidationMode="2.0" maxRequestLength="102400" executionTimeout="360" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="false" targetFramework="4.0" batch="true" numRecompilesBeforeAppRestart="250" optimizeCompilations="true">
<buildProviders>
<add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim" />
</buildProviders>
<assemblies>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="~/Users/Account/AccessDenied" timeout="2880" />
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<customErrors mode="On">
<error statusCode="404" reirect="/" />
</customErrors>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<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.Linq" />
<add namespace="System.Collections.Generic" />
<add namespace="Orchard.Mvc.Html" />
</namespaces>
</pages>
<httpHandlers>
<!-- see below -->
<clear />
<add path="robots.txt" verb="GET" type="System.Web.StaticFileHandler" /><!--allow sitemap.xml and robots.txt to be served-->
<add path="/sitemap.xml" verb="GET" type="System.Web.StaticFileHandler" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<httpModules>
<add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral" />
</httpModules>
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WarmupHttpModule" />
<add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral" />
</modules>
<handlers accessPolicy="Script">
<!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
<clear />
<!--add entries for sitemap.xml and robots.txt-->
<add name="Robots" path="robots.txt" verb="GET" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
<add name="SiteMap" path="/sitemap.xml" verb="GET" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
<!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
<add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script" />
</handlers>
<!-- Prevent IIS 7.0 from returning a custom 404/500 error page of its own -->
<httpErrors existingResponse="PassThrough" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="App_Data/Dependencies" />
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="3.0.0.0" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add invariant="System.Data.SqlServerCe.4.0" name="Microsoft® SQL Server® Compact 4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
</configuration>
Under the <system.web> section of the web.config, make sure you have an entry for sitemap.xml inside the <httpHandlers> block:
<httpHandlers>
<!-- see below -->
<clear />
<add path="robots.txt" verb="GET" type="System.Web.StaticFileHandler" />
<add path="SiteMap.xml" verb="GET" type="System.Web.StaticFileHandler" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
Also make sure you have an entry in system.webserver/handlers that allows sitemap.xml:
<system.webServer>
<handlers accessPolicy="Script,Read">
<!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
<clear/>
<add name="Robots" path="robots.txt" verb="GET" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
<add name="SiteMap" path="SiteMap.xml" verb="GET" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
<!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
<add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script"/>
</handlers>
These mods allow static files like sitemap.xml to be served publicly.
I personally prefer to use Advanced Sitemap module to generate sitemaps. It also takes care about sitemap.xml file accesibillity. You can take a look at it's sources and most likely you will find an answer on your question.
To add the robots.txt the httpHandlers are not necessary, because Orchard is in Integrated mode. Set in the Orchard web.config in the handlers part to script,read:
<handlers accessPolicy="Script,Read">
and add after the <clear/> part these two lines:
<add name="Robots" path="robots.txt" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode" resourceType="File" requireAccess="Read"/>
<add name="Sitemap" path="sitemap.xml" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode" resourceType="File" requireAccess="Read"/>
I'm using Orchard 1.7.2
If somebody's looking this question to figure out how to setup robots.txt only (without a sitemap.xml) then you could use a simple Orchard Robots Module. It gives an easy way to set robots.txt contents without editing web.config or whatsoever.

error 500: ManagedPipelineHandler, deploying web api mvc 4 on azure

I'm trying to deploy a WebAPI project to azure.
When I have a method without SQL access, it shows the result properly as JSON in my browser.
However, when I do anything using Entity framework and just get a test field from the DB then the whole thing errors:
Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler System.Web.Http.WebHost.HttpControllerHandler
Error Code 0x00000000
Things I tried:
When running in the 'Azure compute emulator' everything runs just fine
When using the exact same sql azure connection string in debug it runs just fine
When connecting with RDP to the webrole and telnetting to port 1443 to the SQL azure server, it connects just fine. (so no firewall issue).
What could I try next to find out what is causing this?
Update:
When I point the connectionstring to a local SQLEXPRESS db, it gives the same error. On the local azure emulator it still works
Update:
Screenshot of error which is displayed on a local browser (via rdp)
http://www.proofofconcept.nl/azure_error_screenshot.png
Update:
By popular request. The web.config used
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="Entities" connectionString="metadata=res://*/DAL.Coalition.csdl|res://*/DAL.Coalition.ssdl|res://*/DAL.Coalition.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<!--
<add name="ApplicationServices" connectionString="data source=acbdefgh12.database.windows.net;Initial Catalog=MyCatalog;User ID=database_user#acbdefgh12;Password=MyPassword;Encrypt=true;Trusted_Connection=false;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
<add name="Entities" connectionString="metadata=res://*/DAL.Coalition.csdl|res://*/DAL.Coalition.ssdl|res://*/DAL.Coalition.msl;provider=System.Data.SqlClient;provider connection string="data source=acbdefgh12.database.windows.net;Initial Catalog=MyCatalog;User ID=database_user#acbdefgh12;Password=MyPassword;Encrypt=true;Trusted_Connection=false;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
-->
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" 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" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<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>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="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>
Are you using EF CodeFitst? If so which version? (versions prior 4.3 do have issues with SQL Azure)? Then observe following conditions:
Is your main DbContext named "Entities" or do you explicitly create it with constructor overload which points to "Entities" Connection?
Does your my_dbuser#acbdefgh12 user have access rights to the MASTER DB?
Does the MyCatalog exists prior you deploy the package?
Does your SQL Azure Firewall rules "Allow connections from other Windows Azure Services" (take a look at the screenshot bellow) (I know you mentioned it, but anyway)?
I've been seeing exactly same error when either is true:
my_dbuser#acbdefgh12 does not have access to the Master DB to create the MyCatalaog DB (in case it does not exists)
MyCatalog DB exists but is different from the DbContext model
The main DbContext is named differently than Entities and is created with default parameterless constructor (which in that case uses default EF connection string)
SQL Azure server is not configured to accept connections from other Windows Azure Services
The actual error unfortunately does not show anything useful. As I said I've been seeing exactly the same error when failed to comply with above statements.
What can I suggest to trace the error is to hook / edit your auto generated DbContext file and explicitly throw an exception with the connection string being used just before the connection is open to make sure of the connection string being used.
UPDATE AFTER OVERLOOKING GIVEN Web.Config
Not sure whether this is relevant but I noted that in your web.config the assemblybindings are forcing use of MVC 3.0 if version is lower:
<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>
While instead my web.config for MVC 4 is slightly different for the Web API project type (.NET FX 4.0 / MVC 4):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Very old question, but my issue fairly quickly led me to this page. On an Azure webapp, Entity Framework application I had a 500 error and had a lot of trouble getting any additional information from the logs and traces.
It turns out that my connection string was missing the
MultipleActiveResultSets=true;
attribute. Some pages were working and others were not. Once I added this in, all pages were working.

Is it possible to use ELMAH in a SharePoint environment?

Has anyone integrated ELMAH into their SharePoint environment?
I suppose it's possible as it's all ASP.net, but I just wondered if anyone had done it and if there's a walk through on how to achieve it?
One thing that IS important when setting up ELMAH, or most HTTPModules in Sharepoint is that they need to be at the beginning of the httpModules section. Otherwise SharePoint will essentially swallow the exception and ELMAH functionality will not be invoked
Works
<clear />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
<add name="SPRequest" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
... Rest of SharePoint modules....
Does not work
<clear />
<add name="SPRequest" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
... Rest of SharePoint modules....
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
We use ELMAH in our MOSS 2007 environment. Since ELMAH uses HttpHandlers and is set up via the web.config, activating it was a cinch. Just add the ELMAH stuff to the web.config for the application that you're running inside SharePoint.
If you want ELMAH to report errors at a level higher than your custom application, then add it to the SharePoint web.config.
There is no magic to it, just hook it up like you would on any other ASP.NET site.
Following are the config entries that needs to added in web.config of the SharePoint web application
Add under configsection
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
Add connectionstring section
<connectionStrings>
<add name="elmah-express" connectionString="Data Source=[server name];Initial Catalog= [ELMAH_customlogging];User ID=testuser;Password=Welcome1;" />
</connectionStrings>
Add elmah section just below the connectionstring section
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-express" />
</elmah>
Add handler and module entry in httphandlers and httpmodules section under system.web
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
Add handler and module entry in handlers and modules section under system.webserver
<modules runAllManagedModulesForAllRequests="true">
<remove name="ErrorLog"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" />
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
Please refer below link for elmah implementation in sharepoint
http://sidteche.blogspot.in/2014/08/implement-elmah-custom-logging-in.html

Resources