0

i working in mvc4 with c# web application we have more controller and view in our web application we have configured route for all controller action method in route.config file as

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "User", action = "Login", id = UrlParameter.Optional }
);

it display the url like http://localhost:21638/WebFileViewer/WebDocumentViewer?fileId=21 in all over the application, we have one controller that task is to display the file uploaded by the client in the web browser the file viewer page has url like the above one it displays the file id in the url, i want to hide the query string parameter for this controller only how will i change the route configure file to aspect my requirement?

Expected resultant url: http://localhost:21638/WebFileViewer/WebDocumentViewer

1
  • 1
    What does this have to do with jQuery? Also you can't hide the parameters of a GET. You could instead change your code to use POST request. Commented Feb 6, 2015 at 10:20

1 Answer 1

2

You could use TempData for this:

TempData["FileId"] = "bla";

//this will make sure the data is kept when the user refreshes the page    
TempData.Keep();
RedirectToAction("WebDocumentViewer", "WebFileViewer");

then in WebDocumentViewer retrieve the value of TempData["FileId"].

You won't have to make any changes to your RouteConfig.cs file.

Sign up to request clarification or add additional context in comments.

1 Comment

And what about when the user refreshes the browser?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.