我正在尝试在我的global.asax中进行一些网址重写-类似于微软的这篇文章http://msdn.microsoft.com/en-us/library/system.web.routing.routetable.routes.aspx中的内容
我一直收到错误消息"BC30451:未声明名称'RouteTable‘“。
我已经将以下内容导入到global.asax文件中:
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.Routing.Route" %>
<%@ Import Namespace="System.Web" %>
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
RegisterRoutes(RouteTable.Routes) ' the problem occurs here
End Sub..but它似乎不认识"RouteTable“。
我已经向我的主机提供商确认我使用的是.net 3.5 --尽管我不相信错误消息的底部是这样说的:
版本信息:微软.NET框架版本:2.0.50727.4234;ASP.NET版本:2.0.50727.4223
他们告诉我:
We have receive an update from our system engineers, net 3.5 is basically version 2 with a few add -ons. Similarly 4.5 is references as version 4.
They have also checked other sites on the server and they are also reflected as 2这是正确的,因为我不确定我是否可以做到这一点,而不是在3.5上?
谢谢,
发布于 2013-06-12 19:59:58
好的,看起来即使微软.NET框架版本2.0.50727.4234;可能会出现在屏幕上,仍然可以安装asp.net 3.5版本。我在网上查阅了一些资料,包括这个"asp.net版的疯狂“:
http://blogs.msdn.com/b/jamesche/archive/2007/09/25/asp-net-version-madness.aspx
所以我不认为现在的错误是由运行较低版本引起的。
至于我得到的错误,我认为我需要将以下内容添加到我的web.config中:
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>发布于 2013-06-12 00:08:28
要使用RouteTable,您必须运行3.5 SP1或更高版本。我相信在ServicePack1之前的3.5版本中路由是不可用的,所以我建议确认你的SP1版本至少是3.5。
System.Environment.Version将为您提供此信息,因此您可以尝试此操作来检查您的.net版本号,如下所示:
Response.Write(System.Environment.Version.ToString());
Response.End();或在您的aspx页面中:
<% Response.Write("Version: " + System.Environment.Version.ToString() ) %>https://stackoverflow.com/questions/17046906
复制相似问题