4
I have this include in my project: System.Web.MVC.Ajax
. However when running the application I get an error Runtime, in the archive web.config
. If I comment on the error line on web.config
, error appears in the bottom line, referring to the System.web.MVC.Html
. This is the error that appears:
Server Error in Application '/'.
Build Error
Description: Error when compiling a resource needed to meet this request. Examine the specific details of the error and modify the source code appropriately.
Compiler Error Message: CS0234: The namespace name or type 'Ajax' does not exist in the 'System.Web.Mvc' namespace. You need a Assembly reference?
Error of Origin:
Line 22: Line 23:
Line 24: //here gives the error. Line 25:
Line 26:Source File: c: Projects_mvc Sistema.Mvc Web.config Line: 24
Show Compiler Detailed Output:
Show Full Build Source:
Version Information: Microsoft . NET Framework Version:4.0.30319; Version of ASP.NET:4.0.30319.34249
What I don’t understand is that I have the reference and see the includes of my controller and none is with errors:
using System.Data.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
Well, this is my route file, might be useful:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "BrandContext",
url: "{controller}/{action}/{id}",
defaults: new { controller = "BrandContext", action = "Index", id = UrlParameter.Optional }
);
}
}
And this is my view that I’m starting to create:
@{
ViewBag.Title = "Index";
}
<h2>Index - Teste de Partial View</h2>
In Viewbag is giving the following error.
Viewbag do not exist in the Current context
I just don’t understand what’s really going on.
Below my package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="4.0.4" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net45" />
</packages>
The web.config file
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</configuration>
How’s your
packages.config
?– Leonel Sanches da Silva
I see the installation of each package of your MVC application.
– Leonel Sanches da Silva
This is the second time you have asked me about it. It has to do with references too?
– pnet
Yes, totally, but references are ok. I need your file now
web.config
.– Leonel Sanches da Silva