0

I can't get my request params...

I do a request with ajax by POST method to my services page, in my browser console, the request i well sended like :

localhost/Services/?target=test&action=list&from=test

Send like :

$.ajax({
                    url: '@Url.Action(Url.Content("../Services"))',
                    type: 'POST',
                    data: "target="+$(this).attr('id')+"&action=list&from=test", 
                    dataType: 'string',
                    success: OnSuccess
                });

In my controller, I ve tried :

var context = System.Web.HttpContext.Current;
var q = context.Request.QueryString; //empty
var q2 = context.Request.Url.Query; //empty
// or
var id = Request.QueryString["target"].ToString(); //error - sample on the following link 

Get full query string in C# ASP.NET

What s wrong ?

Community
  • 1
  • 1
Ema.H
  • 2,862
  • 3
  • 28
  • 41

2 Answers2

0

check your global.ascx.cs file for routes. Looks like you dont have the route registered. Check this method RouteConfig.RegisterRoutes(RouteTable.Routes);

qamar
  • 1,437
  • 1
  • 9
  • 12
0

I ve found, it was just like :

var target = Request["target"];

If that can help someone ^^

Ema.H
  • 2,862
  • 3
  • 28
  • 41