2013-04-20 30 views
1

我的global.asax文件。好像asp.net global.asax.cs和global.asax的区别

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.SessionState; 
namespace xxxx 
{ 
    public class Global : System.Web.HttpApplication 
    { 

     protected void Application_Start(object sender, EventArgs e) 
     { 

     }  
    } 
} 

,但是当我看到别人Global.asax文件似乎

<%@ Application Language="C#" %> 
<%@ Import Namespace="System" %> 
<%@ Import Namespace="System.Diagnostics" %> 

<script runat="server"> 

void Application_Start(object sender, EventArgs e) 
{ 
    // Code that runs on application startup 
} 
</script> 

为什么我的Global.asax文件是从他们有什么不同?我使用4.0框架。当我尝试路由时,我的项目不能看到我的路由规则。

回答

2

你“的Global.asax”其实是“的Global.asax.cs” - 您的Global.asax本身可能会是这个样子:

<%@ Application Codebehind="Global.asax.cs" Inherits="x.Global" Language="C#" %> 

Global.asax.cs是什么所谓的代码隐藏文件。这两种方法之间没有真正的功能差异 - 代码隐藏仅仅是为了区分标记和服务器端代码之间的关系。

这与您遇到的任何路由问题无关。

+0

谢谢,但我有关于路由的问题。我的网页无法访问我的路由器,并显示此消息“在路由集合中找不到名为'xxx'的路由”..我认为它有关它。可能吗? – serdar 2013-04-21 00:41:27

+0

您应该用您的完整路线Global.asax/RegisterRoutes和完整堆栈跟踪更新您收到的错误的问题。 – 2013-04-21 09:28:48

相关问题