Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning to a different view
Message
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01596244
Message ID:
01596661
Vues:
49
>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()
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform