Request. UrlReferrer, request. urlreferrer
Recently, a function is to feedback statistics, and then add the page from which to click in the feedback suggestion. At first, we plan to add the & url = Method to the link and then accept the parameters on the page, later I learned about the request. urlReferrer knows that he can directly obtain it, And then directly adds the model to the model. url = Request. urlReferrer. tostring (); later I found that all the URLs on the current page were stored in the database, and I had been wondering where the problem was, and then I checked the information online, this attribute can be obtained only when the page is loaded, that is, the url of the previous page is effective only when I add () The actionresult to add the page action, in addition, the method for adding a model actually obtains the url of the current page.
So I used it like this.
// Add comments public ActionResult Add () {if (Request. UrlReferrer! = Null) {// obtain the last accessed url ViewBag. urllast = Request. UrlReferrer. AbsoluteUri when loading the page;} return View ();}
Then, when adding the model, it will be OK to pass the url in viewbag.