我有NuGet包添加到Web窗体应用程序FriendlyUrls。
在我的RegisterRoutes有:
var settings = new FriendlyUrlSettings();
//settings.AutoRedirectMode = RedirectMode.Off;
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
我创建了2页WebForm1.aspx的和WebForm2.aspx
在WebForm1.aspx的我的头中引用的jQuery v1.9.1的简单相加体内的默认div标签内的以下内容:
<div id="dvResult"></div>
<script type="text/javascript">
$(function() {
$.fpm("GetCategories", '', function (res) {
$("div#dvResult").html(res.d);
}, function (xhr, ajaxOptions, thrownError) {
$("div#dvResult").html("<b>" + thrownError + "</b><br/>Status: " + xhr.status + "<br/>" + xhr.responseText);
});
});
$.fpm = function fpm(methodName, arguments, onSuccess, onError) {
var proto = (("https:" == document.location.protocol) ? "https://" : "http://");
var hostname = window.location.hostname;
if (window.location.port != 80)
hostname = window.location.hostname + ":" + window.location.port;
var loc = proto + "" + hostname + "/WebForm2.aspx";
$.ajax({
type: "POST",
url: loc + "/" + methodName,
data: "{" + arguments + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: onSuccess,
error: onError
});
};
</script>
WebForm2.aspx保持股票的标准将文件添加到项目中,除了加入到后面的代码1种方法之后:
[System.Web.Services.WebMethod(EnableSession = false)]
public static string GetCategories()
{
return "hi";
}
当我运行WebForm1.aspx的我得到以下结果页面:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
当小提琴手查看请求我可以看到友好的URL没有剥离.aspx扩展(这是一件好事):
http://localhost:14918/WebForm2.aspx/GetCategories
但是如上图所示,该FriendlyUrlSettings有AutoRedirectMode设置为RedirectMode.Permanent,当你取消注释RedirectMode.Off行和评论常驻出来,那么你实际上得到“喜”打印屏幕上的结果。
任何人有任何想法是什么原因可能是或如何排除添加到路线?
我曾尝试以下,但它似乎并没有以任何方式401结果我不断收到影响:
//routes.Add(new Route("*Remote.aspx*", new StopRoutingHandler()));
//routes.Ignore("{remote}", new { remote = @".*\Remote.aspx(/.)?" });