Hi,
EDIT I may not have worded my problem very well. The actual problem is not in the routing as much as it is in trying to derive the actual url of the request.
The application can be deployed on many seperate machines. For example
http://localhost:2990/Client/List
etc etc
The reason I can't use Action.Link or html helpers is that I need to build the link before I return it to the view as it populates as grid taking JSON (datatables.net) and NOT and the time the view is being rendered
thanks
I need to populate a grid with a list of items as links pointing to a different controller and action and id.
for example;
when I load the grid the url is as follows: http://localhost:2990/Client
which is fine. The grid contains a link like the following
JSID = "<a href='http://" + RequestUrl + "/trainingdelivery/Get/" + referral.ReferralId + "'>Training Delivery</a>",
the controller is 'trainingdelivery' and action is 'Get' and id = referralid which results in a url like http://localhost:2990/trainingdelivery/Get/12345
). This is fine on my local machine but when we deploy it goes to a server with a different url like http://avapd024/llne.dev:81/
as you can see the 'llne.dev:81' is the IIS web and I need to get the url to wherever it is to recognise its location and go to the correct controller and action.
I tried using the request object and I could probably hack around in there to get it but I would like to know if there are any better solutions?
thanks
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.js/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
AJAX CALL IN JQUERY
oTable = $('#referralTable').dataTable(
{
"bFilter": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"sAjaxSource": "../Client/Fetch",
"aoColumns": [
//client details
{"bVisible": false, "sName": "ReferralId" },
{ "sTitle": "CRN", "sName": "CRN" },
{ "sTitle": "JSID", "sName": "JSID" },
{ "sTitle": "Name", "sName": "Name" }
]
});
the sAjaxSource is the call that loads the grid with data and returns JSON. By the time it is returned it needs to be formatted correctly.