Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();

}
}
Posted
Comments
Hemant Singh Rautela 7-Feb-17 8:26am    
You have to exclude; ScriptResource.axd,WebResource.axd and if any other file used with Capital case....
F-ES Sitecore 7-Feb-17 8:32am    
You could try not doing the redirect if the call is an ajax one. Google "asp.net detect ajax call" and you'll find the code to do that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900