httpmodule

HttpModule only on specific MVC route

安稳与你 提交于 2019-12-01 23:35:22
问题 I have a custom IHttpModule that I would like to only work on a specific route. For example : http://example.com/HandleAzureTask I want this module to only be invoked/handled on the /HandleAzureTask route. Since this is not a controller, I can't really set the [Authorize] attribute on it; how can I force it only to be invoked/handled if user is authenticated? I am on ASP.NET MVC 4 and currently have my module added to web.config as such: <modules> <remove name="AzureWebDAVModule" /> <add name

“500 Internal Server Error” when adding HttpModule in my Website?

蹲街弑〆低调 提交于 2019-12-01 17:29:15
问题 I am having a website (developed in ASP.NET 2.0 (C#)) registered with godaddy.com But when I am adding HttpModule in my web.config as follow: <httpModules> <add type="WwwSubDomainModule" name="WwwSubDomainModule" /> </httpModules> but it gives me "500 Internal Server Error". When I removed the above tag then my website is working fine. Can anyone guess why its creating this problem?? 回答1: Got it guys :) I was facing this problem since last October 2008, but finally I got this why? Instead of

“500 Internal Server Error” when adding HttpModule in my Website?

假如想象 提交于 2019-12-01 17:00:26
I am having a website (developed in ASP.NET 2.0 (C#)) registered with godaddy.com But when I am adding HttpModule in my web.config as follow: <httpModules> <add type="WwwSubDomainModule" name="WwwSubDomainModule" /> </httpModules> but it gives me "500 Internal Server Error". When I removed the above tag then my website is working fine. Can anyone guess why its creating this problem?? Got it guys :) I was facing this problem since last October 2008, but finally I got this why? Instead of adding modules like I have added above in my question, use the following new module syntax made for IIS7

Render a page inside of an HttpModule?

拟墨画扇 提交于 2019-12-01 11:34:57
Anyone got an idea of how to render an aspx page inside of an HttpModule and stream it back to the browser? You can do something like this: Type page_type = BuildManager.GetCompiledType ("~/page.aspx"); Page page = (Page) Activator.CreateInstance (page_type); page.ProcessRequest (Context); public void ProcessRequest(HttpContext context) { using (var writer = new StringWriter()) { context.Server.Execute("default.aspx", writer); context.Response.ContentType = "text/html"; context.Response.Write(writer.GetStringBuilder().ToString()); } } The best way is probably to use URL rewriting to redirect

Render a page inside of an HttpModule?

强颜欢笑 提交于 2019-12-01 09:36:53
问题 Anyone got an idea of how to render an aspx page inside of an HttpModule and stream it back to the browser? 回答1: You can do something like this: Type page_type = BuildManager.GetCompiledType ("~/page.aspx"); Page page = (Page) Activator.CreateInstance (page_type); page.ProcessRequest (Context); 回答2: public void ProcessRequest(HttpContext context) { using (var writer = new StringWriter()) { context.Server.Execute("default.aspx", writer); context.Response.ContentType = "text/html"; context

IIS7 ISAPI Filter Module & HttpModule Events - How do they line up?

放肆的年华 提交于 2019-12-01 07:03:33
So IIS7 in Integrated Pipeline mode uses a IsapiFilterModule to shim ISAPI filter DLL's and fire off the correct "events" on the filters, which is quite different than previous versions of IIS or IIS7 in classic mode because this means that HttpModules fire off right along side ISAPI filters in Integrated Pipeline mode. So does anyone happen to know how ISAPI events ( http://msdn.microsoft.com/en-us/library/ms524855.aspx ) and the HttpModule events ( http://msdn.microsoft.com/en-us/library/ms998536.aspx ) line up? VMAtm HttpModule events are fired after other filters, according to the MSDN: At

What is the best way to upload files with ASP.NET MVC 2?

那年仲夏 提交于 2019-12-01 04:42:55
What is the best method for uploading files of variable size (either very large or very small to an ASP.NET MVC 2 application file system)? This is what I understand so far: It seems like there are two ways that people handle this. (Let's assume the files may be very large or very small) (1) Handle the upload in a controller action via Request.Files or HttpPostedFileBase , which seems to have a drawback of taking a long time because ASP.NET loads the files into active memory. or (2) intercept the file upload early on with an HttpModule which somehow circumvents the performance issue. (I'm a

What is the best way to upload files with ASP.NET MVC 2?

狂风中的少年 提交于 2019-12-01 02:19:43
问题 What is the best method for uploading files of variable size (either very large or very small to an ASP.NET MVC 2 application file system)? This is what I understand so far: It seems like there are two ways that people handle this. (Let's assume the files may be very large or very small) (1) Handle the upload in a controller action via Request.Files or HttpPostedFileBase , which seems to have a drawback of taking a long time because ASP.NET loads the files into active memory. or (2) intercept

IIS treats double-encoded forward slashes in URLs differently on the first request than it does on subsequent requests

99封情书 提交于 2019-11-30 19:53:05
Recently my team was asked to implement an HttpModule for an ASP.NET MVC application that handled double-encoded URLs on IIS 7 and .NET 3.5. Here's the crux of the problem: We sometimes get URLs that have double-encoded forward slashes that look like so: http://www.example.com/%252fbar%5cbaz/foo There are other formats that we have to handle as well, but they all have something in common, they have a double-encoded forward slash. To fix this, we wrote an HttpModule that only acts when a URL has a double encoded forward slash, and we redirect it to a sane URL. The details aren't important, but

Is it possible to modify the content of HttpRequest POST in an IIS HttpModule?

旧城冷巷雨未停 提交于 2019-11-30 19:42:30
I need to modify the content of certain HttpRequests (SSAS connection strings) in IIS. Basically, I need to add an element to the SOAP contained in the request. My approach so far has been to add a Filter to the HttpRequest, and perform the change in the filter's Read method. As far as I can tell, though, Read is never being executed. My understanding of the Request.Filter is that it gets read from when IIS processes the request, so IIS should see my modified Request. Is what I'm trying to do actually possible using an HttpModule and is my Filter approach correct? If so, what would cause Read