I have an asp.net website using the form controls from Telerik. It's just moved to a new server but I keep getting a 500 Internal Server Error.
Removing the httpHandlers section of the web.config makes server error go away, although then it complains if there is a Telerik control on the page. The whole config file is valid XML. Is there anything wrong with this code?
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.826.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
</httpHandlers>
I see you mention it has just moved to a new server. Was this an IIS6 to IIS7+ migration?
IIS7 uses <system.webServer\handlers> instead of the IIS6 <httpHandlers> section. On top of this it will throw an error by default if you have the settings in the old section even if the new section is populated correctly.
Try this:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<!-- modules here -->
</modules>
<handlers>
<!-- modules here -->
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.826.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
</handlers>
</system.webServer>
The validateIntegratedModeConfiguration="false" will allow you to keep your httpHandlers section populated without throwing an error (useful if you are debugging on a cassini / iis6 server) and the entry in the <handlers> section will configure it for your IIS7 server.
The runAllManagedModulesForAllRequests="true" is not strictly required but you will probably find yourself needing it if you are new to configuring IIS7 :)
Is the new server perhaps running IIS7?
Then try this
<system.webServer>
<handlers>
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.826.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
</handlers>
</system.webServer>
Also, make sure you have the exact version that you have specified in the Handlers section. You do not actually need the Version, Culture, and Public Token parameters specified in your web.config in order for it to work. They are there incase you are using more than one version in your application. Without them being specified, the server will use the first one that it finds referenced in your project. So, if you are only using one version of an assembly, you can omit the parameters.
Make sure that you have the Telerik DLL Telerik.Web.UI.dll referenced in your project and that CopyLocal is set to "true". Also, make sure (using File | Properties) that you have the right version on the server, too.
Related
I have been developing an application that was hosted on IIS 6 and we have just upgraded our server that uses IIS 8.5 but can't get it to work on the new server.
The application has a custom handler that's called when a file with extension .XmlDataTypes is requested.
For this to work in IIS6 I set up a mapping as:
Extension: '.XmlDataTypes'
Path: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll'
Verbs: All.
In Web.config:
<httpHandlers>
<add verb="*" path="*.XmlAmenityData" type="XmlHandler"/>
<add verb="*" path="*.XmlDataTypes" type="XmlDataTypes"/>
</httpHandlers>
And this works fine.
In IIS8.5 I've tried adding a Managed Handler with:
Requested path: '*.XmlDataTypes'
Type:, selected 'XmlDataTypes'
Name: XmlDataTypes
This then added to the web.config file:
<system.webServer>
<handlers>
<add name="XmlAmenityData" path="*.XmlAmenityData" verb="*" type="XmlHandler" resourceType="File" preCondition="integratedMode" />
<add name="XmlDataTypes" path="*.XmlDataTypes" verb="*" type="XmlDataTypes" resourceType="File" preCondition="integratedMode" />
</handlers>
</system.webServer>
When I run a page that requests a URL with extension .XmlDataTypes via a jQuery function I just get an 404 not found error.
Thanks in advance for any help.
J.
It looks like those are files on your disk. If they are, your solution could be as simple as adding the following to your web.config under "system.webServer".
<staticContent>
<mimeMap fileExtension=".XmlAmenityData" mimeType="application/xml" />
<mimeMap fileExtension=".XmlDataTypes" mimeType="application/xml" />
</staticContent>
That's it.
However, if you are really relying on HTTP Handlers, please note that the "Type" need to be fully qualified with the assembly name at the least.
So your type need to include the namespace as well.
In your code, "XmlHandler" isn't fully qualified with the namespace and the assembly isn't mentioned. Ensure that it is.
Finally, change the "resourceType" to "Unspecified" or IIS will ensure that a file truly exist before executing your handler.
None of the answers I've found here or on similar questions on stackoverflow worked for me.
I'm using IIS 8.5, .Net v4.0, Integrated, and was still getting a 404 with the following handler config:
<system.webServer>
<handlers>
<add name="testEmail" path="*.em" verb="*" type="MyApp.testRazorEmailHandler, MyApp" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
I enabled tracing and found the following :
116. -HANDLER_CHANGED
OldHandlerName testEmail
NewHandlerName System.Web.Mvc.MvcHandler
NewHandlerModules ManagedPipelineHandler
NewHandlerScriptProcessor
NewHandlerType System.Web.Mvc.MvcHandler, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
As you can see it looks like it had correctly picked up the request using my custom HttpHandler testEmail but MVC had stolen it.
I opened my route definitions in RouteConfig.cs and found that adding:
routes.IgnoreRoute("{resource}.em");
I got it to ignore requests meant for my Handler.
Hope this helps someone - I was tearing my hair out!
I am getting 404 not found status codes for my minified javascripts files and also there is an error ASP.Net ajax client side framework failed to load.
I have given my configuration settings in the web.config below,
<httpModules>
<!-- Component Art-->
<add type="ComponentArt.Web.UI.UploadModule,ComponentArt.Web.UI" name="ComponentArtUploadModule"/>
<!--Blog Engine-->
<add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
<add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
<add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
<add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
<!--Remove the default ASP.NET modules we don't need-->
<remove name="PassportAuthentication"/>
<remove name="Profile"/>
<remove name="AnonymousIdentification"/>
</httpModules>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</modules>
<handlers>
<add name="ComponentArtScriptHandler" type="ComponentArt.Web.UI.ScriptHandler,ComponentArt.Web.UI" path="ComponentArtScript.axd" verb="*" />
</handlers>
</system.webServer>
I cant figure out whether I am missing any configuration or added something extra. Can somebody have a look
If you're getting "not found" error, there's something wrong with resolving the path. Either the path/file doesn't exist (because it's somewhere else for instance), or you have some conflicting rules in rewrite/routing engine.
Try to use, as a temporary fix, absolute paths. That means instead of
href="../../my.js"
you'd write
href="http://mypage.com/js/my.js"
Similar to #walther
href="/js/my.js"
As the first slash will take the path to the root of the URL, so useful for when moving between different environments (provided your dev isn't in a subfolder).
I have a webservice which defines a custom httpmodule. I am attempting to launch this webservice onto a production server running IIS7 but have only been able to get it to run in Classic mode.
I have tried moving this section
<system.web>
<httpModules>
<add name="BasicAuthenticationModule" type="MyProject.UserAuthenticator.UserNameAuthenticator" />
</httpModules>
...
To the system.webserver section like so:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="BasicAuthenticationModule" type="MyProject.UserAuthenticator.UserNameAuthenticator" />
</modules>
When I try this IE gives me this error:
Config Error
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to
'BasicAuthenticationModule'
I also attempted to migrate automatically with the following DOS command:
appcmd migrate config "mysite/"
And get this message back:
The module BasicAuthenticationModule with type "mytype" is already present in the application with a different type"", and was not migrated
I am not an IIS expert so any insights are appreciated.
So after a little research it appears there is already a native module called BasicAuthenticationModule. I can eliminate my issue by renaming my module "BasicCustomAuthenticationModule." Is this the correct approach or should I be removing the other one?
Thanks!
AFrieze
Their was a conflict in the name BasicAuthenticationModule. The solution was to rename the module.
<httpModules>
<add name="BasicCustomAuthenticationModule" type="MyProject.UserAuthenticator.UserNameAuthenticator" />
</httpModules>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="BasicCustomAuthenticationModule" type="MyProject.UserAuthenticator.UserNameAuthenticator" />
</modules>
I am having problems trying to map an HttpHandler in the web.config.
This is the relevant config bit:
<httpHandlers>
<add verb="*" path="*.hndlr" type="MyAssembly.MyHandler, MyAssembly" validate="false" />
</httpHandlers>
When I navigate to http://localhost/myApp/whatever.hndlr I am getting a server error 404 (not found).
It's the 1st time I am hooking up an HttpHandler so I might be missing something - any help appreciated!
UPDATE:
I managed to get it working using both answers so far - who's able to explain why it works gets the answer marked!
This is my config (won't work if you don't have both - I am running IIS7 in classic mode)
System.web:
<httpHandlers>
<add verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false"/>
</httpHandlers>
System.webserver:
<handlers>
<add name="MyHandler" verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
Are you using IIS7, if so is the application pool running in classic or pipelined mode? If it is IIS7 in pipelined mode then the handler reference needs to go into the following section
<system.webServer>
<handlers>
</handlers>
<system.webServer>
rather than in the following section.
<system.web>
<httpHandlers>
</httpHandlers>
</system.web>
Just as a guide for those stuck with this problem I found the crucial attribute to be..
resourceType="Unspecified"
I originally followed a Microsoft example to set this up and they had it as
resourceType="File"
which just kept giving me 404 errors. My HTTPHandler is returning graphics.
Hope this helps :)
i am using IIS7, the solution is:
in section
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="CVOS.MyDocumentHandler"/>
</httpHandlers>
<system.web>
and section
<system.webServer>
<handlers>
<add name="pdfHandler" verb="*" path="*.ashx" type="CVOS.MyDocumentHandler" />
</handlers>
</system.webServer>
What is the extension of your handler? If you are using a custom extension like .hndlr you may also need to add a ScriptMap in IIS and point it to the ASP.NET runtime so that IIS can forward the request to the correct processor.
In IIS7 go to your website
Under the IIS group go to Handler Mappings
Under Actions click Add Script Map
Set Request Path to *.hndlr
Set Path to the ASP.NET runtime (%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll) or whatever version you are running.
Then in your web.config you will need to register the handler in the appropriate section as described in the other answer.
It is also possible to experience this error if you have set up the handler for 32 bit, but you are running in 64 bit (or vice versa). It's easy to set up both and have all the bases covered.
Note "preCondition", and "scriptProcessor" differences.
<handlers>
<add name="MyHandler_32bit" verb="*" path="*MyHandler.hndlr" preCondition="bitness32" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="MyHandler_64bit" verb="*" path="*MyHandler.hndlr" preCondition="bitness64" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
</handlers>
None of the previous answers worked for me.
I'm using IIS 8.5, .Net v4.0, Integrated, and was still getting a 404 with the following handler config:
<system.webServer>
<handlers>
<add name="testEmail" path="*.em" verb="*" type="MyApp.testRazorEmailHandler, MyApp" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
I enabled tracing and found the following :
116. -HANDLER_CHANGED
OldHandlerName testEmail
NewHandlerName System.Web.Mvc.MvcHandler
NewHandlerModules ManagedPipelineHandler
NewHandlerScriptProcessor
NewHandlerType System.Web.Mvc.MvcHandler, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
As you can see it looks like it had correctly picked up the request using my custom HttpHandler testEmail but MVC had stolen it.
I opened my route definitions in RouteConfig.cs and found that adding:
routes.IgnoreRoute("{resource}.em");
I got it to ignore requests meant for my Handler.
Hope this helps someone - I was tearing my hair out!
Hopefully my solution will help others. On a server move from IIS6 to 7.5, both .Net 4.0 Integrated, I had a Captcha control that quit working. It turns out that removing this attribute preCondition="integratedMode,runtimeVersionv2.0" from the <add> node in <system.webserver><handlers> resolved the issue.
This seems to be an edge case, but I had a customer where our httpHandler used in our application did not work on any of their servers. The handler pointed to an .ashx page and it was called from JavaScript.
The handler mapping showed up in IIS, the handler factory was there, but I would get a 404 when the browser requested the ashx page associated with the handler. After many different attempts to fix we finally browsed to the file in IIS on the server and it specifically showed a 404.7 being returned with this message.
•Request filtering is configured for the Web server and the file extension for this request is explicitly denied.
•Verify the configuration/system.webServer/security/requestFiltering/fileExtensions settings in applicationhost.config and web.config.
If you get this then Request Filtering is enabled for the .ashx extension at either your app or site level. Go to the Request Filtering option in IIS at both your site and app level and verify that the extension is not blocked. There are two different ways Request Filtering can be configured.
The default seems to be that it explicitly blocks only file extensions that are configured in the list (blacklist). The other way it can be configured is that only files specifically configured as allowed in the list are let through (whitelist). This second option is how the customer had configured all of their Windows Servers by default and it turns out that the .ashx file extension was not in the list of allowed extensions.
This is the first thread that appears when I look for a verb that responds with a 404. In my case the solution was a configuration of VS
Tools > Options > Web projects > [x] Use 64 bit version
Sorry, my VS is in spanish
I'm getting the following error on a webpage. We recently migrate a website from IIS6 to IIS7, its my first exposure to IIS7. We have'nt closed the other domain yet, and the site is running all fine (so we can compare until migration is fully completed.)
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.
The solution is very curious. Though IIS7 in error description says to add SessionStateModule to system.web section, it should be added to system.webServer section.
<system.webServer>
<modules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</modules>
</system.webServer>
<system.web>
<httpModules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
</httpModules>
</system.web>
Above code works fine!!!
If using in , then this code does not have any effect.