<small id='4Clhb'></small><noframes id='4Clhb'>

<tfoot id='4Clhb'></tfoot>
<legend id='4Clhb'><style id='4Clhb'><dir id='4Clhb'><q id='4Clhb'></q></dir></style></legend>
    <i id='4Clhb'><tr id='4Clhb'><dt id='4Clhb'><q id='4Clhb'><span id='4Clhb'><b id='4Clhb'><form id='4Clhb'><ins id='4Clhb'></ins><ul id='4Clhb'></ul><sub id='4Clhb'></sub></form><legend id='4Clhb'></legend><bdo id='4Clhb'><pre id='4Clhb'><center id='4Clhb'></center></pre></bdo></b><th id='4Clhb'></th></span></q></dt></tr></i><div id='4Clhb'><tfoot id='4Clhb'></tfoot><dl id='4Clhb'><fieldset id='4Clhb'></fieldset></dl></div>

        <bdo id='4Clhb'></bdo><ul id='4Clhb'></ul>

    1. 是否可以使用 HttpModule 删除一些帖子数据?

      Is it possible to remove some post data with an HttpModule?(是否可以使用 HttpModule 删除一些帖子数据?)

          • <i id='Pc0nm'><tr id='Pc0nm'><dt id='Pc0nm'><q id='Pc0nm'><span id='Pc0nm'><b id='Pc0nm'><form id='Pc0nm'><ins id='Pc0nm'></ins><ul id='Pc0nm'></ul><sub id='Pc0nm'></sub></form><legend id='Pc0nm'></legend><bdo id='Pc0nm'><pre id='Pc0nm'><center id='Pc0nm'></center></pre></bdo></b><th id='Pc0nm'></th></span></q></dt></tr></i><div id='Pc0nm'><tfoot id='Pc0nm'></tfoot><dl id='Pc0nm'><fieldset id='Pc0nm'></fieldset></dl></div>
          • <legend id='Pc0nm'><style id='Pc0nm'><dir id='Pc0nm'><q id='Pc0nm'></q></dir></style></legend>

              <small id='Pc0nm'></small><noframes id='Pc0nm'>

              <tfoot id='Pc0nm'></tfoot>
                <bdo id='Pc0nm'></bdo><ul id='Pc0nm'></ul>
                  <tbody id='Pc0nm'></tbody>
                本文介绍了是否可以使用 HttpModule 删除一些帖子数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在将一个旧的经典 asp 网站转换为 asp.net.

                I'm converting an old classic asp website to asp.net.

                该应用程序基本上是针对给定用户集的工具集的扩展,但它由外部供应商托管.

                The application is basically an extension of a tool set for a given set of users but it is hosted at an external vendor.

                为了执行到这个应用程序的无缝传输,它会发布一些 xml 数据,这些数据会触发潜在危险的 Request.Form 值".我知道我可以关闭 validateRequest 标志,但我不想这样做.

                To perform a seamless transfer to this application it POSTS some xml data which is firing off the "potentially dangerous Request.Form value". I know I could turn off the validateRequest flag but I would rather not do this.

                我已经编写了一个 httpmodule,它获取这些数据并使用它来验证用户,是否可以使用相同的模块或不同的模块来删除之前发布数据中的这些坏"值数据已验证"?

                I have written an httpmodule which takes this data and uses it to authenticate the user, is it possible to use the same module, or a different module for that matter, to remove these "bad" values in the post data before that data is "validated"?

                否则,如果这些想法都不起作用,我愿意接受其他建议.

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

                推荐答案

                是的.以下类实现 IHttpModule 接口并注册和事件,这些事件将在 HttpRequestValidationException 检查发生之前触发.它检查请求是 POST 并且testinput"不为空,然后对其进行 HTML 编码.该类需要在您的 Web.config 中注册为 httpModule.

                Yes. The following class implements the IHttpModule Interface and registers and event that will fire before the HttpRequestValidationException check occurs. It checks that the request is a POST and that "testinput" is not null and then HTML Encodes it. The Class needs to be registered in your Web.config as an httpModule.

                类...

                using System;
                using System.Collections.Specialized;
                using System.Reflection;
                using System.Web;
                
                public class PrevalidationSanitizer : System.Web.IHttpModule
                {
                    private HttpApplication httpApp;
                
                    public void Init(HttpApplication httpApp)
                    {
                        this.httpApp = httpApp;
                        httpApp.PreRequestHandlerExecute += new System.EventHandler(PreRequestHandlerExecute_Event);
                    }
                
                    public void Dispose() { }
                
                    public void PreRequestHandlerExecute_Event(object sender, System.EventArgs args)
                    {
                        NameValueCollection form = httpApp.Request.Form;
                
                        Type type = form.GetType();
                
                        PropertyInfo prop = type.GetProperty("IsReadOnly", BindingFlags.Instance 
                            | BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                
                        prop.SetValue(form, false, null);
                
                        if (httpApp.Request.RequestType == "POST" != null 
                            && httpApp.Request.Form["testinput"])
                                httpApp.Request.Form.Set("testinput"
                                    , httpApp.Server.HtmlEncode(httpApp.Request.Form["testinput"]));
                    }
                }
                

                web.config 条目...

                web.config entry...

                <system.web>
                  <httpModules>
                    <add type="PrevalidationSanitizer" name="PrevalidationSanitizer" />
                ...
                

                这篇关于是否可以使用 HttpModule 删除一些帖子数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                Cannot remove items from ListBox(无法从列表框中删除项目)
                Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                How do I get at the listbox item#39;s quot;keyquot; in c# winforms app?(如何获取列表框项目的“键?在 c# winforms 应用程序中?)
                Problem getting list box items added through jquery in code behind(在后面的代码中通过 jquery 添加列表框项目时出现问题)
                <tfoot id='XJwoz'></tfoot>

                        <bdo id='XJwoz'></bdo><ul id='XJwoz'></ul>

                        <small id='XJwoz'></small><noframes id='XJwoz'>

                        <legend id='XJwoz'><style id='XJwoz'><dir id='XJwoz'><q id='XJwoz'></q></dir></style></legend>

                            <tbody id='XJwoz'></tbody>

                        1. <i id='XJwoz'><tr id='XJwoz'><dt id='XJwoz'><q id='XJwoz'><span id='XJwoz'><b id='XJwoz'><form id='XJwoz'><ins id='XJwoz'></ins><ul id='XJwoz'></ul><sub id='XJwoz'></sub></form><legend id='XJwoz'></legend><bdo id='XJwoz'><pre id='XJwoz'><center id='XJwoz'></center></pre></bdo></b><th id='XJwoz'></th></span></q></dt></tr></i><div id='XJwoz'><tfoot id='XJwoz'></tfoot><dl id='XJwoz'><fieldset id='XJwoz'></fieldset></dl></div>