I am able to do the URL rewriting of my MVC Application by using a Route.Config
file as below:
//Offline Consult Route
routes.MapRoute(
name: "WrittenStep2",
url: "written/step2/{id}",
defaults: new { controller = "Offline", action = "Step2", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Written",
url: "written",
defaults: new { controller = "Offline", action = "Index" }
);
In the above code, I have Controller as "Offline" and have some actions.
I am able to change the route:
TO: www.abc.com/written
FROM www.abc.com/Offline
My problem is that I am still able to access the URL: www.abc.com/Offline. How can I resolve this issue?
I have tried to deny access of this URL to the users by using the Begin_Request
method of Global.asax
file.
But after doing that I won't be able to access my methods which I am calling using jQuery Ajax.
$.ajax({
type: "POST",
url: "/Offline/HelloWorld",
data: jsonString,
contentType: "application/json",
...
Is there any way to restrict users from using the same URL?