简体   繁体   中英

“Name 'Url' is not declared” when I try to use Url.Content()

I have an ASP.NET site that is not currently using MVC but I'm trying to convert it to MVC slowly. The first time I tried using Url.Content in an .aspx page I got:

Name 'Url' is not declared

I then added:

<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

and:

<add namespace="System.Web.Mvc"/>

to the appropriate places in the web.config file, but it had no effect.

Your page needs to inherit from ViewPage so you'll need a page directive like this at the top of the aspx page...

<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

Also, not sure if you've seen it but this article by Maarten Balliauw might help :-)

http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM