Hosting ASP applications without IIS... in IIS7 mode! Permissionproblems with handlers & Web.config

L

Luis Serrano

Hi All,

I have quiet a complex problem here, and I am not sure this is the
correct group to ask about it.

I'll try to explain as much as I can to provide enough information, so
if someone has faced similar experiences or has deeper knowledge, I'd
be grateful to hear all about it.

As the title of my post states, I have created windows service that
hosts ASP.Net applications. I have managed to do it, I can process
aspx pages, asmx, and also set tup http handlers through the
web.config file.

But there are some limitations I needed to solve, for example, being
able to access the HttpResponse.Headers collection within handler -
implementing IHttpHandler-.

In:

public void ProcessRequest(HttpContext context)
{ ..},

the Headers collection isn't available, because it is not running on
IIS7 pipeline mode. I can't add headers either, I've tried
Headers.Add, Response.AddHeaders and Response.AppendHeader. None of
them works and I definitely need to send headers back to another
application, that's firing the request to my handler.

After reading this:

http://community.discountasp.net/showthread.php?t=5770
and http://www.sitepoint.com/article/web-config-file-demystified/

I saw that I could "emulate" the IIS7 behavior, moving my handlers
from <system.web> to <system.webServer>.

This is what I had (and worked):

<system.web>

<authorization>
<allow users="?" verbs="POST, GET"/>
</authorization>

<authentication mode="None"></authentication>

<compilation>
<assemblies>
<add assembly="eBDHandlers, version=1.0.0.1, culture=neutral,
publickeytoken=6d75eac878142816"/>
</assemblies>
</compilation>
<httpHandlers>
<add verb="*"
path= "*.ebd"
type= "eBD.Handlers.TestHandler, eBDHandlers,
version=1.0.0.1, culture=neutral, publickeytoken=6d75eac878142816" />
</httpHandlers>
</system.web>

All requests to whatever.ebd fire the TestHandler. That's what I want,
though I don't have access to Response.Headers withing the handler.

But if instead of adding the handler in system.web, I do it in
system.webServer, like this:

<system.webServer>
<security>
<authentication mode='None'>
<anonymousAuthentication enabled='true'/>
</authentication>
<authorization>
<add accessType='Allow' roles='Admin' verbs='GET,POST'/>
<!--Access rule to allow users with role 'Admin' -->
<add accessType='Allow' users='?'/>
<!--Access Rule to allow all users -->
</authorization>
</security>

<handlers>
<clear />
<!-- <add name="Wildcard" path="*" verb="*"
modules="IsapiModule" resourceType="Unspecified"
scriptProcessor="%windir%\Microsoft.NET\Framework
\v2.0.50727\aspnet_isapi.dll" />-->
<remove path="*" verb="GET,HEAD,POST" />
<add name ="testHandler"
verb="*"
path= "*.ebd"
type= "eBD.Handlers.TestHandler, eBDHandlers,
version=1.0.0.1, culture=neutral, publickeytoken=6d75eac878142816"
resourceType="Unspecified" />
</handlers>
</system.webServer>

I get the following in every request (except for those that match to
an existing document, then it works):

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The HTTP verb POST used to access path '/CombinedSolowest/
addtocart.aspx_22010007' is not allowed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The HTTP verb POST used
to access path /LocalScript/whatever.ebd' is not allowed.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The HTTP verb POST used to access path '/
LocalScript/whatever.ebd' is not allowed.]

System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context,
AsyncCallback callback, Object state) +463
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
() +505
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +191
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

'/LocalScript' is the virtual path for the hosted application, and
'whatever.ebd' is the url used to trigger the handler. It works with
the HttpHandler informed within <system.web><httpHandlers>.

I've tried many combinations, I've read everything about IIS 7 and
it's configuration files, I've tried adding permissions to All users
and all verbs, an yet nothing seems to work.

Could it be that I can't really emulate the IIS7 behavior? I have also
noted that the error pages is informing of an error in the .Net
Framework 2.0.50727.3082 version, but all my assemblies are compiled
and intended to work with 3.5.

Anyone has a clue of what I am doing wrong?

Thank you in advance. If I find a solution I'll post it so everyone
suffering the same situation can read it.

Cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top