I am very new to programming in general, and to ASP.NET MVC.
I am experimenting with publishing a basic MVC project on my shared windows server ( Hostgator. I have the windows personal plan http://www.hostgator.com/windows-hosting )
The trust level of the server should be set to medium (full only for dedicated servers)
- I created an ASP.NET web application, empty MVC project.
- I created a home controller and returned a string. So far the webpage worked.
However when I created a view for my action method to return, and changed the code to " return View();" the application stops working and I get the error message:
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Line 4: <meta charset="utf-8" /> Line 5: <meta name="viewport" content="width=device-width, initial-scale=1.0"> Line 6: <title>@ViewBag.Title - My ASP.NET Application</title> Line 7: <link href="~/Content/Site.css" rel="stylesheet" type="text/css" /> Line 8: <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
Does an MVC application by default need a trust level = "full" ? or is there something else I can do here? Please explain in simple terms.
To sum up, these are the working and non-working version. When I introduce the return View() things starts going to shits.
Working version:
// Controller
public class HomeController : Controller
{
public string Index()
{
return "this is working";
}
}
// View
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
Not-working version:
// Controller
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
// View
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>