从iis浏览mvc3应用程序时出错? [英] Getting error when browsing mvc3 application from iis?
问题描述
嗨
我在HomeController.cs中创建了一个mvc3 application.in,其中包含以下方法。
public JsonResult StringReturn()
{
string s =hai;
返回Json(s);
}
然后从views /调用上述方法主页/ Index.cshtml使用
jquery如下
函数GetString(){
$ .ajax({
类型:POST,
url: Home / StringReturn,
contentType:application / json; charset = utf-8,
dataType:json,
data :'{}',
错误:函数(jqXhr,textStatus,errorThrown){
alert(Error'+ jqXhr.status +'(textStatus:' + textStatus +',errorThrown:'+ errorThrown +'));
},
成功:函数(result,textStatus){
提醒(结果);
}
});
}
当我工作时从visual studio运行它。但是当我从托管的iis浏览它时收到错误消息'错误405(textStatus:'error',errorThrown:'undefined')'
.how解决这个问题?
谢谢..
Hi
I created a mvc3 application.in which the below method inside HomeController.cs.
public JsonResult StringReturn()
{
string s="hai";
return Json(s);
}
then calling the above method from views/Home/Index.cshtml using
jquery as below
function GetString() {
$.ajax({
type: "POST",
url: "Home/StringReturn",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: '{}',
error: function (jqXhr, textStatus, errorThrown) {
alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')");
},
success: function (result, textStatus) {
alert(result);
}
});
}
it work when i run it from visual studio.but getting error message 'Error 405(textStatus:'error',errorThrown:'undefined')'
when i browse it from hosted iis.how to resolve this?
thanks..
推荐答案
.ajax({
类型:POST,
url:Home / StringReturn,
contentType:application / json; charset = utf-8,
dataType:json,
数据:'{}',
错误:函数(jqXhr, textStatus,errorThrown){
alert(Error'+ jqXhr.status +'(textStatus:'+ textStatus +',errorThrown:'+ errorThrown +'));
},
成功:函数(结果,textStatus){
alert(result);
}
});
}
当我从visual studio运行时它工作。但是收到错误信息'错误405(textStatus:'错误',errorThrown:'undefined')'
当我从托管的iis.how浏览它来解决这个问题?
谢谢..
.ajax({
type: "POST",
url: "Home/StringReturn",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: '{}',
error: function (jqXhr, textStatus, errorThrown) {
alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')");
},
success: function (result, textStatus) {
alert(result);
}
});
}
it work when i run it from visual studio.but getting error message 'Error 405(textStatus:'error',errorThrown:'undefined')'
when i browse it from hosted iis.how to resolve this?
thanks..
尝试使用以下代码。
Try using the following piece of code.
[HttpPost]
public JsonResult StringReturn()
{
string s="hai";
return Json(s);
}
这篇关于从iis浏览mvc3应用程序时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!