Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning to a different view
Message
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01596244
Message ID:
01596661
Views:
48
>Hi Viv, just to clarify, I put
>
>ViewBag.Caller = Request.UrlReferrer; // in the HttpGet method for Edit ?
>input type="hidden" name="caller" value="@ViewBag.Caller" // In the Edit.cshtml ( angle brackets remove for UT )
>
>
>where do I then get access to this to do the Redirect - must be in the HttpPost method I guess ?, thanks for your help
>
>Edit
>Sussed it, added string caller to the HttpPost Edit method, much better way thanks.

If you're using a form you don't need to specifically add the caller - you could just access it on the server via : Request.Form["caller"]

Also, if, for example, the View you wanted to return to was on the same controller you could just do:
string s = Request.Form["caller"];
return View(s.Substring(s.LastIndexOf('/') + 1));
thus avoiding the Redirect()
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform