404使用急性字符进行POST时

时间:2015-03-09 21:10:55

标签: jquery asp.net-mvc iis

当我向其发送POST时,我的反馈控制器回复404 Not Found,带有表单数据的JQuery AJAX,当任何字段包含急性字符(áíóú)时,但如果没有,则可以正常工作。我检查了两个请求的标题,唯一的区别是长度和急性字符本身。

我试图找到问题,但我似乎无法弄明白。

我应该在JQuery自动执行的URL编码之上执行某种编码吗?

编辑:

这是我的控制器Post方法:

[System.Web.Mvc.HttpPost]
public JsonResult Post(FeedbackViewModel model)
{
    ...
}

这是我的FeedbackViewModel:

public class FeedbackViewModel
{
    //Llenado por MVC
    public string Name { get; set; }
    public string Email { get; set; }

    //Llenado por Javascript
    public string Environment { get; set; }

    //Llenado por Usuario
    [Required]
    [MaxLength(254)]
    public string Summary { get; set; }

    [Required]
    [MaxLength(1000)]
    public string Description { get; set; }

    public static FeedbackViewModel Create(AppContext appContext)
    {
        return new FeedbackViewModel
        {
            Name = appContext.CurrentUser.FullName,
            Email = appContext.CurrentUser.Email
        };
    }
}

我的JavaScript

dialog = BootstrapDialog.show({
    title: "Feedback",
    message: "Connecting to Visum...",
    type: "type-default",
    closable : true,
    onshow: function (dialog) {
        dialog.enableButtons(false);
        $.ajax({
            url: "/Feedback"
        }).always(processData).fail(function(data) {
            dialog.setType(BootstrapDialog.TYPE_DANGER);
            dialog.setMessage("An unexpected error occured");
        }).success(function(data) {

        });
    },
    buttons: [
        {
            icon: "glyphicon glyphicon-send",
            label: "Submit",
            cssClass: "btn-primary",
            id: "btn-send",
            action: function (dialog) {
                var summary = dialog.getModalBody().find("#title").val();
                var description = dialog.getModalBody().find('#desc').val();
                if ($.trim(summary).length == 0) {
                    alert(dialog.data.summaryValidate);
                    return false;
                } else if ($.trim(description).length == 0) {
                    alert(dialog.data.commentValidate);
                    return false;
                }
                dialog.enableButtons(false);
                dialog.setClosable(false);

                dialog.data.data.Description= description;
                dialog.data.data.Summary= summary;
                dialog.data.data.Image= image_data;
                dialog.data.data.Environment=
                        "Location: " + window.location.href + "; \n" +
                        "Refferer: " + document.referrer + "; \n" +
                        "Browser CodeName: " + navigator.appCodeName + "; \n" +
                        "Browser Name: " + navigator.appName + "; \n" +
                        "Browser Version: " + navigator.appVersion + "; \n" +
                        "Cookies Enabled: " + navigator.cookieEnabled + "; \n" +
                        "Browser Language: " + navigator.language + "; \n" +
                        "Browser Online: " + navigator.onLine + "; \n" +
                        "Platform: " + navigator.platform + "; \n" +
                        "User-agent header: " + navigator.userAgent + "; \n";

                $.ajax({ type: "POST", url: dialog.data.postUrl, data: dialog.data.data,  }).always(function data() {
                    setTimeout(function () {
                        dialog.close();
                    }, 5000);
                }).success(function (data) {
                    dialog.setType(BootstrapDialog.TYPE_SUCCESS);
                    dialog.setMessage("Feedback sent, this dialog will close in 5 seconds");

                }).fail(function (data) {
                    dialog.setType(BootstrapDialog.TYPE_DANGER);
                    dialog.setMessage("An unexpected error occured, this dialog will close in 5 seconds");

                });

            }
        }
    ]
});

没有急性字符的请求:

Remote Address:191.238.240.12:80
Request URL:http://visumdevelop.azurewebsites.net/Feedback/Post
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:es
Connection:keep-alive
Content-Length:657
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:__RequestVerificationToken=cQ3i-o1oc-FCG6E-jH4zGvvT_jZDiCTc6T3sxsiCoev0bTbS1qZQs6pELHXlnwQl6Kb9tQZD2OSXPfrvuTSHwpPCUb2jbdlqdv4Cd-    ojkLY1; ASP.NET_SessionId=gy2xgbolalfi350qzdrhv3ti; ARRAffinity=ba9e0a23e4392153bdbbc0e711ccce8c551bdcf826855839d26c9823bcd080e3; .AspNet.    ApplicationCookie=WMaJFzn_RUEKlddRBi4_rg83_UcGDJvnk-vhjtPnvUqeN8If_3DIS3jQeqCBLeVB_mYR6HT4_AicuY-    HlrNdNDPLvgPTOacCk2vZTZQNRbtUn7Wk4C1rCTR45K27FyRdzqXB4xqilzt5vQiBG1ppexLR-C-entHfCoSaEtqPw2h3jxgEZsrnyT-HTUt-ZLxfJ0AOO_qN31xZnOfG2tV77Z-    sl7rPUXE_ZHCHPPGMZ51IMqi2CyiJArKpKtFqplnHVuNLMhM-93j9WeXVnU5Wsc29DgB_8P2aJPQ89mN95tJN8I8ZmXi4JnkQIVpEqPn0mkk_2o466fTtibZ0C0hnDx1DVd98ZNOIM-    Qoxm476LUCGIel4-kX7lgmA2BoJQHR4KD8f9fBjiF3xdOjdHJjw6bU_0JVKURo6S3yipHAxPm-    PZtkmcj6QMtlWsrp8rvBnUJF5qDUpi_sX9bODzxv8rZg0S2XErCzgdGx02vilDOhp6j8_FdMosheLoEFACyR
DNT:1
Host:visumdevelop.azurewebsites.net
Origin:http://visumdevelop.azurewebsites.net
Referer:http://visumdevelop.azurewebsites.net/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
Name:Adminsitrador de Visum
Email:visumadmin@incostas.com
Environment:Location: http://visumdevelop.azurewebsites.net/; 
Refferer: ; 
Browser CodeName: Mozilla; 
Browser Name: Netscape; 
Browser Version: 5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36; 
Cookies Enabled: true; 
Browser Language: en-us; 
Browser Online: true; 
Platform: Win32; 
User-agent header: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36; 
Summary:TEST
Description:TEST aiou
Response Headersview source
Cache-Control:private
Connection:keep-alive
Content-Encoding:gzip
Content-Length:212
Content-Type:application/json; charset=utf-8
Date:Mon, 09 Mar 2015 21:29:11 GMT
Server:Microsoft-IIS/8.0
Vary:Accept-Encoding
Via:1.0 localhost (squid)
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Cache:MISS from localhost
X-Cache-Lookup:MISS from localhost:3128
X-Powered-By:ASP.NET

使用急性角色提出的请求:

Remote Address:191.238.240.12:80
Request URL:http://visumdevelop.azurewebsites.net/Feedback/Post
Request Method:POST
Status Code:404 Not Found
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:es
Connection:keep-alive
Content-Length:677
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:__RequestVerificationToken=cQ3i-o1oc-FCG6E-jH4zGvvT_jZDiCTc6T3sxsiCoev0bTbS1qZQs6pELHXlnwQl6Kb9tQZD2OSXPfrvuTSHwpPCUb2jbdlqdv4Cd-    ojkLY1; ASP.NET_SessionId=gy2xgbolalfi350qzdrhv3ti; ARRAffinity=ba9e0a23e4392153bdbbc0e711ccce8c551bdcf826855839d26c9823bcd080e3; .AspNet.    ApplicationCookie=WMaJFzn_RUEKlddRBi4_rg83_UcGDJvnk-vhjtPnvUqeN8If_3DIS3jQeqCBLeVB_mYR6HT4_AicuY-    HlrNdNDPLvgPTOacCk2vZTZQNRbtUn7Wk4C1rCTR45K27FyRdzqXB4xqilzt5vQiBG1ppexLR-C-entHfCoSaEtqPw2h3jxgEZsrnyT-HTUt-ZLxfJ0AOO_qN31xZnOfG2tV77Z-    sl7rPUXE_ZHCHPPGMZ51IMqi2CyiJArKpKtFqplnHVuNLMhM-93j9WeXVnU5Wsc29DgB_8P2aJPQ89mN95tJN8I8ZmXi4JnkQIVpEqPn0mkk_2o466fTtibZ0C0hnDx1DVd98ZNOIM-    Qoxm476LUCGIel4-kX7lgmA2BoJQHR4KD8f9fBjiF3xdOjdHJjw6bU_0JVKURo6S3yipHAxPm-    PZtkmcj6QMtlWsrp8rvBnUJF5qDUpi_sX9bODzxv8rZg0S2XErCzgdGx02vilDOhp6j8_FdMosheLoEFACyR
DNT:1
Host:visumdevelop.azurewebsites.net
Origin:http://visumdevelop.azurewebsites.net
Referer:http://visumdevelop.azurewebsites.net/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
Name:Adminsitrador de Visum
Email:visumadmin@incostas.com
Environment:Location: http://visumdevelop.azurewebsites.net/; 
Refferer: ; 
Browser CodeName: Mozilla; 
Browser Name: Netscape; 
Browser Version: 5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36; 
Cookies Enabled: true; 
Browser Language: en-us; 
Browser Online: true; 
Platform: Win32; 
User-agent header: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36; 
Summary:TEST
Description:TEST áíóú
Response Headersview source
Cache-Control:private
Connection:keep-alive
Content-Length:103
Content-Type:text/html
Date:Mon, 09 Mar 2015 21:30:58 GMT
Server:Microsoft-IIS/8.0
Via:1.0 localhost (squid)
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Cache:MISS from localhost
X-Cache-Lookup:MISS from localhost:3128
X-Powered-By:ASP.NET

1 个答案:

答案 0 :(得分:1)

Jira API要求具有UTF-8字符的内容具有正确的标题。

然而,问题与我的计划没有任何关系。它实际上是由防火墙导致请求(剥离utf-8编码头)的错误导致的,该请求针对防火墙后面的Jira API。