重写URL后,Ajax调用无法正常工作以生成小写 [英] Ajax call not working after rewrite URL for making lowercase

查看:64
本文介绍了重写URL后,Ajax调用无法正常工作以生成小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在global.asax文件中编写了一个以小写形式创建Url的代码。我的ajax电话无法正常工作。

它会返回我的结果。任何人都可以帮助我



如果我从global.asax删除规则那么它可以工作。

任何人都可以帮助我。



提前致谢



我的尝试:



这是我在aspx页面中的ajax调用函数

$ .ajax({



类型:POST,

url:siteRoot +default.aspx / getSearchResult,

contentType:application / json,

数据:JSON.stringify({

searchBox:request.term,

}),

成功:函数(数据){

}



这是我在global.asax文件中的URL规则

protected void Application_BeginRequest(object sender,EventArgs e)

{

if(Regex.IsMatch(HttpContext.Current.Request.Url.ToString(),@[ AZ]))

{



//小写网址

字符串lower = HttpContext.Current.Request.Url.ToString()。ToLower();



//重新定义回复

HttpContext.Current.Response.Clear();

HttpContext.Current.Response.Status =301永久移动 ;

HttpContext.Current.Response.AddHeader(位置,更低);

HttpContext.Current.Response.End();



}

}

I write a code for make Url in Lowercase in global.asax file. my ajax call not working.
it returns me html insted of my result. can any one help me

if I remove the rule from global.asax then it works.
Can any one help me.

Thanks in advance

What I have tried:

This is my ajax call function in aspx page
$.ajax({

type:"POST",
url: siteRoot+"default.aspx/getSearchResult",
contentType: "application/json",
data: JSON.stringify({
searchBox: request.term,
}),
success: function (data) {
}

This is my URL Rule in global.asax file
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Regex.IsMatch(HttpContext.Current.Request.Url.ToString(), @"[A-Z]"))
{

// Lowercase url
String lower = HttpContext.Current.Request.Url.ToString().ToLower();

// Redefine response
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", lower);
HttpContext.Current.Response.End();

}
}

推荐答案

.ajax({



类型:POST,

url:siteRoot +default.aspx / getSearchResult,

contentType:application / json,

数据:JSON.stringify({

searchBox:request.term,

}),

成功:函数(数据) {

}



这是我在global.asax文件中的URL规则

protected void Application_BeginRequest(object sender,EventArgs e)

{

if(Regex.IsMatch(HttpContext.Current.Request.Url.ToString(),@[AZ]))

{



//小写网址

字符串lower = HttpContext.Current.Request.Url.ToString()。ToLower();



//重新定义回复

HttpContext.Current.Response.Clear();

HttpContext.Current.Response.Status =301永久移动;

HttpContext.Current.Response.AddHeader(位置,更低);

HttpContext.Current.Response.End();



}

}
.ajax({

type:"POST",
url: siteRoot+"default.aspx/getSearchResult",
contentType: "application/json",
data: JSON.stringify({
searchBox: request.term,
}),
success: function (data) {
}

This is my URL Rule in global.asax file
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Regex.IsMatch(HttpContext.Current.Request.Url.ToString(), @"[A-Z]"))
{

// Lowercase url
String lower = HttpContext.Current.Request.Url.ToString().ToLower();

// Redefine response
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", lower);
HttpContext.Current.Response.End();

}
}


这篇关于重写URL后,Ajax调用无法正常工作以生成小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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