Skip to content

Instantly share code, notes, and snippets.

@d2funlife
Created September 20, 2017 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d2funlife/791283390539224c408f56c7ef6cc647 to your computer and use it in GitHub Desktop.
Save d2funlife/791283390539224c408f56c7ef6cc647 to your computer and use it in GitHub Desktop.
ViewResult
namespace System.Web.Mvc
{
public class ViewResult : ViewResultBase
{
private string _masterName;
public string MasterName
{
get { return _masterName ?? String.Empty; }
set { _masterName = value; }
}
protected override ViewEngineResult FindView(ControllerContext context)
{
ViewEngineResult result = ViewEngineCollection.FindView(context, ViewName, MasterName);
if (result.View != null)
{
return result;
}
//генирация исключения со всеми местами, где искали файл представления
StringBuilder locationsText = new StringBuilder();
foreach (string location in result.SearchedLocations)
{
locationsText.AppendLine();
locationsText.Append(location);
}
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
MvcResources.Common_ViewNotFound, ViewName, locationsText));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment