WebForms 和 ASP.NET MVC 共存 [英] WebForms and ASP.NET MVC co-existence

查看:21
本文介绍了WebForms 和 ASP.NET MVC 共存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据 这个问题.我为实现这一目标所做的一件事是,我向 WebForms web.config 添加了一个命名空间节点:

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I've done to make that happen is that I added a namespaces node to the WebForms web.config:

<pages styleSheetTheme="Default">
  ...
  <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>

但是,当我尝试启动项目时,我收到一条错误消息:编译器错误消息:CS0234:命名空间System.Web"中不存在类型或命名空间名称Mvc"(是您缺少程序集参考?)"

However, when I try to start the project, I get an error stating: "Compiler Error Message: CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)"

我引用了 System.Web.Mvc.有什么问题?

I have System.Web.Mvc referenced. What is the issue?

推荐答案

在编译部分添加System.Web.Mvc

<compilation debug="true">
    <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </assemblies>
</compilation>

这篇关于WebForms 和 ASP.NET MVC 共存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆