JSON参数自动。当转换ajax请求到MVC操作方法作出小写? [英] JSON parameters auto. convert to lowercase when ajax request made to MVC action method?

查看:221
本文介绍了JSON参数自动。当转换ajax请求到MVC操作方法作出小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会有人知道为什么我的参数被转换,当它击中我的ASP.NET MVC控制器操作为小写?

Would anybody know why my parameter is being "converted" to lowercase when it hits my ASP.NET MVC controller action?

我只能假设它是被换算成看着数据值之前,为了Ajax请求是按照正确的外壳,但随后的AJAX请求期间调试.NET中我的操作方法,并检查传入的参数时,有被转换为小写?

I can only assume it is being converted as looking at data value just prior to the ajax request it is in correct casing, but then when debugging my action method within .NET during the ajax request and checking the incoming parameter, it has been converted to lowercase?

因为我需要保持用户输入的情况下这是造成我的电视剧

This is causing dramas for me as I need to keep the case entered by the user.

低于code,正在发送数据的例子是: SimpleDATATest1

Code below, example data being sent is: 'SimpleDATATest1'

$.ajax({
    type: "GET",
    url: "/configuration/module-message-types/GetTranslation",
    data: "messageToTranslate=" + messageToTranslate,
    dataType: "json",
    success: function(result) {
        // Insert the returned HTML into the <div>.
        $('#TranslationResponse').html(result.message).fadeIn('fast');
        $("#" + ajaxLoadImgId).hide();
    },
    error: function(req, status, error) {
        $('#TranslationResponse').text('Could not load example translation message, please try reloading the page.');
        $("#" + ajaxLoadImgId).hide();
    }
});

和MVC行动的方法签名是:

And MVC Action method signature is:

[AcceptVerbs(HttpVerbs.Get)]
    public JsonResult GetTranslation(string messageToTranslate)

然而,检查messageToTranslate它是为返回的值时: simpledatatest1

如何才能停止工作无论从力量改变这个?

How can I stop whatever forces at work from changing this?

推荐答案

没关系...我发现这一点,我实现是罪魁祸首:

HTTP://www.$c$crjournal。 COM / 2008/03 /力MVC-路由URL小写/

Nevermind... I found this that I implemented was the culprit:
http://www.coderjournal.com/2008/03/force-mvc-route-url-lowercase/

这篇关于JSON参数自动。当转换ajax请求到MVC操作方法作出小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆