Disabling request validation on Azure Websites

落花浮王杯 提交于 2019-12-11 03:47:32

问题


My node.js application runs nicely on my own machine, however, after pushing it up to an Azure WebSite using Git, I'm getting request validation problems.

Some of my requests are trapped by the IIS validation process. The fix is to add this to the web.config:

<httpRuntime requestPathInvalidCharacters=""/>

I downloaded the web.config from the site\wwwroot folder of my website using FTP, added it to the repo, added the new element in the XML, and pushed it back up to Azure.

My web.config file seems to have been overridden by the default.

Is there a way of changing this behaviour? Or another way of turning off request validation? Or am I just being thick?

UPDATE

I take it all back, it seems to be express which is blocking the request. However, the question still stands as 'how do I customise my web.config?'


回答1:


Could you try setting a custom validation type? Like this:

  <httpRuntime requestPathInvalidCharacters=""
               requestValidationType="MyValidator, MyAssembly"/>

And the class:

public class MyValidator : RequestValidator
{
    protected override bool IsValidRequestString(HttpContext context, string value, RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)
    {
       validationFailureIndex = 0;
       return true;
    }
}


来源:https://stackoverflow.com/questions/13630918/disabling-request-validation-on-azure-websites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!