asp.net - Is it possible to remove some post data with an HttpModule? -


I am converting to an old classic ASP website asp.net

This app is basically an extension of a set of tools for a given set of users but it is hosted on an external vendor.

In order to make this application seamless, it posts some XML data that is closing "potentially dangerous request. Farm value". I know that I can close the valid recognition flag, but I can not do this.

I have written an httpmodule that takes this data and uses it to authenticate the user, whether it is possible to use the same module, or a separate module for that matter, " Is "valid" before deleting these "bad" values ​​in the "data"?

Otherwise if none of these ideas works, then I am open to other suggestions.

Yes the following class implements the IHttpModule interface and registers and events that will fire before the HttpRequestValidationException probe. It checks that the request is a post and "testinput" is not zero and then encodes HTML. The class must be registered as a httpModule in your Web.config.

class ...

  using the system; Using System.Collections.Specialized; Using the system. Using System.Web; Public Class Preceding Citizenship: Systems Web. IHTP module {Private HTTPPTPXAPAP; Public Zero Init (HttpApplication httpApp) {this.httpApp = httpApp; HttpApp.PreRequestHandlerExecute + = New System. Enventhandler (prequesthandlerAxactIvent); } Public Zero removal () {} Public Zero PreRequestHandlerExecute_Event (Object Sender, System.EventArgs args) {NameValueCollection Form = httpApp.Request.Form; Type type = form.GetType (); PropertyInfoProp = Type. Getproperty ("israel only", bindingflaag.instance; bindingflog.improve case; bindingfalag nonpolic | bindingflag.flatanahairacqua); Prop.SetValue (form, incorrect, empty); If (httpApp.Request.RequestType == "POST"! = Null & amp; httpApp.Request.Form ["testinput"]) httpApp.Request.Form.Set ("testinput", httpApp.Server.HtmlEncode (httpApp. .form ["testinput"])); }}  

web.config entry ...

  & lt; System.web & gt; & Lt; HttpModules & gt; & Lt; Add type = "PrevalidationSanitizer" name = "PrevalidationSanitizer" /> ...  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -