I've created a new MVC project in Visual Studio 2013 and after creating a view with an empty template (with model) and using a layout page (set to empty), I receive the following:
This causes the view to render incorrectly. I have tried searching for the solution elsewhere to no avail. Cleaning/Rebuilding of the solution does not help either. What's annoying is that it does this on a brand new project.
Any ideas on how to fix?
Additional Info:
Views/Web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="WebShopPortal.Web" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
DownloadViewModel
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace WebShopPortal.Web.ViewModels
{
public class DownloadViewModel
{
public string ProductId { get; set; }
public string DisplayText { get; set; }
public string DownloadUrl { get; set; }
public string OptionalReturnText { get; set; }
[Required(ErrorMessage = "Title is required")]
public string Title { get; set; }
[DisplayName("First Name")]
[Required(ErrorMessage = "First name is required")]
public string FirstName { get; set; }
[DisplayName("Last Name")]
[Required(ErrorMessage = "Last name is required")]
public string LastName { get; set; }
[DisplayName("Job Title")]
public string JobTitle { get; set; }
[DisplayName("Company Name")]
[Required(ErrorMessage = "Company name is required")]
public string CompanyName { get; set; }
[DisplayName("Company Type")]
public int CompanyTypeId { get; set; }
[DisplayName("Address Line 1")]
public string Address1 { get; set; }
[DisplayName("Address Line 2")]
public string Address2 { get; set; }
[DisplayName("Address Line 3")]
public string Address3 { get; set; }
[DisplayName("Address Line 4")]
public string Address4 { get; set; }
[DisplayName("City/Town")]
public string Town { get; set; }
[DisplayName("State/County")]
public string County { get; set; }
[DisplayName("Zip/Postcode")]
public string Postcode { get; set; }
public string Country { get; set; }
[DisplayName("Phone Number")]
public string WorkTelephone { get; set; }
[DisplayName("Fax")]
public string WorkFax { get; set; }
[DisplayName("Email Address")]
[EmailAddress(ErrorMessage = "Invalid Email Address")]
[Required(ErrorMessage = "Email address is required")]
public string EmailAddress { get; set; }
public bool DoNotNotify { get; set; }
public string ReturnUrl { get; set; }
//Dropdowns
public IEnumerable<SelectListItem> TitleList { get; set; }
public IEnumerable<SelectListItem> CompanyTypeList { get; set; }
public IEnumerable<SelectListItem> CountryList { get; set; }
}
}
_ViewStart.cshtml
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
And I can promise you nothing funky is going on in the _Layout page.
Simply closing and reopening the solution seems to make the error disappear.
Pages are rendering fine too. Weird it happens to me after creating a fresh project. I will monitor to see if it happens again in future.
It's a long shot but you could try this steps:
Taken from this thread, maybe can help you. It's worth to try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With