문제

I'm trying out some URL rewriting within my global.asax - similar to what's going on in this microsoft article http://msdn.microsoft.com/en-us/library/system.web.routing.routetable.routes.aspx

I'm keep getting the error "BC30451: Name 'RouteTable' is not declared."

I have imported the following into the global.asax file:

<%@ 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 it doesn't seem to recognise "RouteTable".

I have checked with my hosting providers that I am on .net 3.5 - although I'm not convinced as at the bottom of the error message says:

Version Information: Microsoft .NET Framework Version:2.0.50727.4234; ASP.NET Version:2.0.50727.4223

They told me :

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

Is this correct as I'm not sure if I can do this and not be on 3.5?

Thanks,

도움이 되었습니까?

해결책

Ok, it would appear that even though Microsoft .NET Framework Version:2.0.50727.4234; might appear on screen, version asp.net 3.5 could still be installed. I've checked out a few sources online, including this "asp.net version madness" :

http://blogs.msdn.com/b/jamesche/archive/2007/09/25/asp-net-version-madness.aspx

So I don't believe the error is now caused by running a lower version.

As for the error I'm getting, I think I need to add this to my web.config:

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

다른 팁

You must be running 3.5 SP1 or later to use RouteTable. I believe that routing wasn't available in 3.5 before Service Pack 1, so I would recommend verifying that you are on at least 3.5 SP1.

The System.Environment.Version will get you this information so you you can try this to check your .net version number like so in your code behind:

Response.Write(System.Environment.Version.ToString());
Response.End();

Or in your aspx page:

<% Response.Write("Version: " + System.Environment.Version.ToString() ) %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top