Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 380 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"The name 'HTML' does not exist in the current context" in MVC 3 Views

#1
I´m starting to use "MVC 3" but I´m facing some little problems. In my Views, when I code something like this:

@if(Request.IsAuthenticated) {
<text>Welcome <b>@Context.User.Identity.Name</b>!
[ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text>
}
else {
@:[ @Html.ActionLink("Log On", "LogOn", "Account") ]
}

The objects like @Request and @Html is indicating an error: `The name 'HTML' does not exist in the current context`.

The same occurs with @Context, @ViewBag, @Layout, @Url and others.

See:

[![image][1]][1]
<!-- source:

[To see links please register here]

-->

[1]:


But the code is correctly compiled with no errors. The problem is that I cannot use the Intellisense with theses objects in the Views. Is it normal? (I don´t think so). What could be happening?

I have reinstalled the MVC 3 framework but the same still occurs.

Note: this is a new project from scratch, not a MVC 2 migration. This occurs both with Razor engine and ASPX.

This is the Web.Config in the Views folder:

<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.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=3.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.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />

<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>




Thanks!
Reply

#2
I have solved this issue with the old, good, wise Microsoft default solution: reinstall all the things again.

Uninstall and Reinstall the Visual Studio 2010 and MVC 3 Framework.
Reply

#3
For me this just seemed to be the fact that I had compiler warnings. Code would still compile and run ok but it was not until I fixed all the build warnings that my Intellisense starting working.
Reply

#4
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>

solution for this problem in web.config
Reply

#5
I experienced this on ASP.NET MVC 4 as well, after uninstalling EntityFramework from my packages list.

I had to remove this section
> `<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, .... `

that's left on the Web.config file... at the least it removed the errors from the errors list
Reply

#6
I tried to *remove* the project that is still in trouble from solution and add it back again, after which the problem had been gone.
Reply

#7
I had this same issue in MVC 4. None of these solutions worked for me. Instead, in Windows, I went into Control Panel -> Uninstall a program. Select Microsoft ASP.NET MVC 4 in the program list. Click 'Uninstall.' A 'Microsoft ASP.NET MVC 4 Setup' wizard will display. Click 'Repair.'
Reply

#8
Clean your solution and Under references.
Then set the follow property:

System.Web.MVC file to Copy Local = True.
Reply

#9
What worked for me was closing Visual Studio, deleting the user option files (both solution and project level), then relaunching Visual Studio.
Reply

#10
Set the property of System.Web.MVC,Copy Local = True
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through