I have a partial view (control) that\'s used across several view pages, and I need to pass the name of the current view back to the controller - so if there\'s e.g. validati
I had the same issue recently and the snippet of code I came up with solved my issue.
The only downfall is that Request.UrlReferrer could be null in some cases. Bit late but seemed to work for me and I covered all the bases of Request.UrlReferrer not being null.
if (Request.UrlReferrer != null)
{
var viewUrl = Request.UrlReferrer.ToString();
var actionResultName = viewUrl.Substring(viewUrl.LastIndexOf('/'));
var viewNameWithoutExtension = actionResultName.TrimStart('/');
}