处理程序和权限的权限问题Web

处理程序和权限的权限问题Web

本文介绍了在IIS7模式下托管没有IIS的ASP应用程序!处理程序和权限的权限问题Web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在这里,我已经解决了一个复杂的问题,我不确定这是不是要问这个问题的正确小组.

我会尽力尽我所能解释,以提供足够的信息,因此,如果有人遇到过类似的经历或有更深的知识,我将不胜感激.我创建了承载ASP.Net应用程序的Windows服务.我已经做到了,我可以处理aspx页面,asmx,还可以通过web.config文件设置tup http处理程序.

但是我需要解决一些限制,例如,能够在处理程序-实现IHttpHandler-中访问HttpResponse.Headers集合.

在:

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)
{..}



标头集合不可用,因为它不在IIS7管道模式下运行.我也无法添加标题,我尝试了Headers.Add,Response.AddHeaders和Response.AppendHeader.它们都不起作用,我绝对需要将标头发送回另一个应用程序,这会将请求触发给我的处理程序.

阅读此内容后:

http://www.sitepoint.com/article/web-config-file-demystified/

我看到我可以模仿" IIS7行为,将我的处理程序从< system.web>到< system.webServer>.

这就是我曾经(并且曾经工作过)的内容:



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:

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>


对所有内容的所有请求.ebd触发 TestHandler .那就是我想要的,
尽管我无法访问带有处理程序的Response.Headers.

但是,如果不是在system.web中添加处理程序,我可以在
中进行/> system.webServer,例如:

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 '/LocalScript/whatever.ebd' 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"是托管应用程序的虚拟路径,"whatever.ebd"是用于触发处理程序的URL.它可以与< system.web>< httpHandlers>中通知的HttpHandler一起使用.

我尝试了许多组合,已经阅读了有关IIS 7及其配置文件的所有信息,向所有用户和所有动词添加权限,似乎还没有任何效果.

可能是我无法真正模仿IIS7的行为吗?我还注意到错误页面通知了.Net Framework 2.0.50727.3082版本中的错误,但是我所有的程序集均已编译并打算与3.5一起使用.

任何人都知道什么我做错了吗?

谢谢你.如果找到解决方案,我将其发布,以便所有人在相同情况下都能阅读.

干杯!

Luis Serrano
西班牙巴塞罗那

推荐答案

感谢您的帖子!我建议您以

首页


这篇关于在IIS7模式下托管没有IIS的ASP应用程序!处理程序和权限的权限问题Web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:15