Limiting HttpModule to only process certain requests

We use directory browsing on a specific section of our website, but our users don't really like the default ASP.NET directory browsing. To be honest, we don't particularly care for it either. I came across mvolo's custom directory browsing module and I attempted to use it. However, I discovered that if I have it enabled in my root web.config, it allows directory browsing on all

限制HttpModule只处理某些请求

我们在我们网站的特定部分使用目录浏览,但我们的用户并不喜欢默认的ASP.NET 目录浏览。 说实话,我们并不特别关心它。 我遇到了mvolo的自定义目录浏览模块,我试图使用它。 但是,我发现如果在根web.config中启用它,它将允许在没有默认页面的情况下在所有文件夹上浏览目录(如您所期望的那样)。 如果我在根中设置了enabled =“false”,它会抛出一个HttpException,它被我的通用错误页面捕获,但是每个请求都会导致异常

Httpmodule resend/ recreate request

I have created an httpmodule that gets user ip information and append credentials to the header based on their IP. It does this every request though. I would like to listen for a 401 status response and then run the ip look up and resend the request through. I have all the pieces in place, i can catch the 401 error, and attach credentials to a header, except i cannot figure out how to resend

Httpmodule重新发送/重新创建请求

我创建了一个httpmodule,它获取用户ip信息,并根据IP将信息追加到头部。 它虽然每个请求都这样做。 我想倾听401状态响应,然后运行ip查找并重新发送请求。 我有所有的部分,我可以捕捉到401错误,并将凭据附加到标题,但我无法弄清楚如何通过新标题重新发送请求。 可能传输或重写? 我不会详细说明你为什么选择这样的策略,因为这听起来不太优雅。 无论如何,考虑到你的要求,我会在响应中设置两个cookie,使用身份验

> loading and displaying one by one

Here I put my sample code. Please correct the mistake. In the sample code I want to load the update panels “UpdatePanelBodySub1”, “UpdatePanelBodySub2”, “UpdatePanelBodySub3” and “UpdatePanelBodySub4” one by one. If one updatepanel loaded all records then immediately that will come to display, then next updatepanel will start work … . Please help me. (Visual Studio 2008 and Framework 3.5)

>逐个加载并显示

在这里我把我的示例代码。 请纠正错误。 在示例代码中,我想逐个加载UpdatePanelBodySub1,UpdatePanelBodySub2,UpdatePanelBodySub3和UpdatePanelBodySub4。 如果一个updatepanel立即加载所有记录并立即显示,那么下一个updatepanel将开始工作...。 请帮帮我。 (Visual Studio 2008和Framework 3.5) Default.aspx的 主页 - 多个UpdatePanel <UsrCtrl:MainControl ID="mainControl1" runat="server" Enab

ASP.net Custom Http Modules

Running IIS 7 I'm trying to implement a custom Http Module, what I actually want is to implement gzip compression. There seems to be a few ways to do this. I am trying to do this by accessing the HttpApplication.BeginRequest event and add some code there that will use gzip. I am using umbraco so I don't have a global.asax file so what I have got is a class file inside the app code

ASP.net自定义Http模块

运行IIS 7 我试图实现一个自定义的Http模块,我真正想要的是实现gzip压缩。 似乎有几种方法可以做到这一点。 我试图通过访问HttpApplication.BeginRequest事件并添加一些代码来使用gzip。 我使用的是umbraco,所以我没有global.asax文件,所以我得到的是我的网站的应用程序代码文件夹内的一个类文件: public class GzipHttpCompressionModule : IHttpModule { public GzipHttpCompressionModule() {} public void Disp

How to end request with 404 in an IHttpModule?

I'm writing a new IHttpModule. I would like to invalidate certain requests with 404 using a BeginRequest event handler. How do I terminate the request and return a 404? You can explicitly set the status code to 404 like: HttpContext.Current.Response.StatusCode = 404; HttpContext.Current.Response.End(); Response will stop executing. 你可以试试throw new HttpException(404, "File Not Foun

如何在一个IHttpModule中使用404结束请求?

我在写一个新的IHttpModule。 我想用404使用BeginRequest事件处理程序使某些请求无效。 我如何终止请求并返回404? 你可以显式设置状态码为404,如下所示: HttpContext.Current.Response.StatusCode = 404; HttpContext.Current.Response.End(); 响应将停止执行。 你可以试试throw new HttpException(404, "File Not Found"); 另一种可能性是: HttpContext.Current.Response.StatusCode = 404; HttpContext.Current.Re

HTTP Response filter can't decode the response bytes the second time

I developed an IIS 7 HttpModule. My goal is to check the response content for a particular tag. if the tag is found then something gets logged. To achieve my goal I developed a customized ASP NET Response Filter. This filter extends the .NET Stream class. The filter get registered on the OnPreRequestHandlerExecute(Object source, EventArgs e) event. The HTTP module has been registered cor

HTTP响应过滤器无法第二次解码响应字节

我开发了一个IIS 7 HttpModule。 我的目标是检查特定标签的响应内容。 如果找到标签,则会记录一些内容。 为了实现我的目标,我开发了一个定制的ASP NET Response Filter。 此过滤器扩展了.NET Stream类。 过滤器在OnPreRequestHandlerExecute(Object source,EventArgs e)事件上注册。 HTTP模块已被正确注册。 过滤器正在工作。 问题是,当我刷新页面时,写入写入(byte []缓冲区,int偏移量,int count)方法会按

How to dispose IHttpModule correctly?

All implementation of IHttpModule I've seen looks following: class HttpCompressionModule : IHttpModule { public void Init(HttpApplication application) { application.SomeEvent += OnSomeEvent; } private void OnSomeEvent(Object source, EventArgs e) { // ... } public void Dispose() { // nothing here !!! } } I am wondering why is the Dispose method always empty?

如何正确处理IHttpModule?

IHttpModule的所有实现我看过以下内容: class HttpCompressionModule : IHttpModule { public void Init(HttpApplication application) { application.SomeEvent += OnSomeEvent; } private void OnSomeEvent(Object source, EventArgs e) { // ... } public void Dispose() { // nothing here !!! } } 我想知道为什么Dispose方法总是空的? 我们不应该取消订阅我们在Init方法中订阅的事

Why does RouteLink generate friendly URL while ActionLink does not?

I have a question regarding RouteLink vs. ActionLink. Consider the following route routes.MapRoute("Routename1", "{someEnum}/SpecificAction/{id}/{stringId}", new { controller = "MyController", id = (int?)null, stringId= (string)null, action = "SpecificAction" }, new { someEnum= "(EnumVal1|EnumVal2)" } ); The weird {someEnum} part is because I use a general controller for all value

为什么RouteLink会生成友好的URL,而ActionLink不会呢?

我有一个关于RouteLink与ActionLink的问题。 考虑以下路线 routes.MapRoute("Routename1", "{someEnum}/SpecificAction/{id}/{stringId}", new { controller = "MyController", id = (int?)null, stringId= (string)null, action = "SpecificAction" }, new { someEnum= "(EnumVal1|EnumVal2)" } ); 奇怪的{someEnum}部分是因为我使用一个通用控制器来处理一个枚举的所有值,这些值构成了url的典型控制器部分。

choosing a diagramming library for .Net

I have a customer who needs to convert a diagramming application (which was developed in MFC a long time ago) to C#. The application displays large networks (lots of graphical elements), and lets the user edit/manipulate the data through a graphical ui. I decided that it would be best to use a library rather than to develop all from scracth (all graphic objects/selection/tools/events/etc) I

为.Net选择一个图表库

我有一位客户需要将绘图应用程序(很久以前在MFC中开发)转换为C#。 该应用程序显示大型网络(大量图形元素),并允许用户通过图形用户界面编辑/操作数据。 我决定最好使用一个库,而不是从scracth开发所有(所有图形对象/选择/工具/事件/等) 我正在寻找一个商业解决方案。 我发现三个看起来非常成熟,我想知道是否有人使用过它们并且可以写下他/她的意见: Tom Sawyer可视化 用于.Net的IBM ILog Diagrammer yWor

Cast to not explicitly implemented interface?

Let's say you define some arbitrary interface: public interface IInterface { void SomeMethod(); } And let's say there are some classes that happen to have a matching public interface, even though they do not "implement IInterface ". IE: public class SomeClass { public void SomeMethod() { // some code } } Is there nevertheless a way to get an IInterface re

强制转换为未明确实现的接口?

假设你定义了一些任意的接口: public interface IInterface { void SomeMethod(); } 假设有一些类碰巧拥有匹配的公共接口,尽管它们没有“实现IInterface ”。 IE: public class SomeClass { public void SomeMethod() { // some code } } 是否还有一种方法可以获得对SomeClass实例的IInterface引用? IE: SomeClass myInstance = new SomeClass(); IInterface myInterfaceReference = (IInterface)my