jov c

jov c

  • NA
  • 13
  • 1.3k

create url routing in global.asax with jquery query string

May 3 2019 4:44 AM
i tried url routing using global.asax..its working for home.aspx..but not working for Details.aspx?name=jo having querystring...
  1. void Application_Start(object sender, EventArgs e)  
  2. {  
  3. RegisterRoutes(RouteTable.Routes);  
  4. }  
  5. public void RegisterRoutes(RouteCollection routes)  
  6. {  
  7. routes.MapPageRoute("Home""Home""~/Home3.aspx");  
  8. routes.MapPageRoute("Details""Details{name}""~/Details.aspx");//error  
  9. }  
my url changed from http://localhost:34345/Home3.aspx to http://localhost:34345/Home ..
i use jquery ajax in my project...here data is passed through query string for details.aspx using jquery... so while using global.asax,i cannot read data from query string..i am getting an error.. ... here is the query string code page1
  1. $("#btnsubmit").click(function () {  
  2. var Textdata = $('#txtdata').val();  
  3. var url = "Details?name=" + encodeURIComponent(Textdata);  
  4. window.location.href = url;  
  5. });  
  6. Details.aspx..  
  7. function getdealsearch() {  
  8. var name = window.location.search.split('=')[1] == undefined ? '' : window.location.search.split('=')[1];  
  9. $.ajax({  
  10. type: "POST",  
  11. url: "/WebService.asmx/Getbyname",  
  12. data: '{Name:"' + name+ '"}',  
  13. contentType: "application/json; charset=utf-8",  
  14. dataType: "json",  
  15. .....  
  16. ....  
  17. ......  
  18. }  
when added Details.aspx to global.asax ..i am getting an error as HTTP Error 404.0 - Not Found ...and the the link shown is http://localhost:56105/Details?name=jo how can i convert the link to http://localhost:56105/Details/jo..plese reply..thanks in advance

Answers (1)