当我创建Global.Asax.Cs页面时,什么是命名空间..... [英] What Will Be A Namespace When I Create Global.Asax.Cs Page.....

查看:189
本文介绍了当我创建Global.Asax.Cs页面时,什么是命名空间.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建Global.asax.cs页面时,那将是命名空间....



案例,



在global.asax.cs页面



命名空间---------

{

公共类Global:System.Web.HttpApplication

{



protected void Application_Start(object sender, EventArgs e)



在这种情况下我无法理解为什么我们使用Global.asax.cs页面后面的代码....

解决方案

通常,global.asax会引用项目命名空间中的Global类,如下所示:



<%@ Application Codebehind =Global.asax.csInherits =WebApplication1.GlobalLanguage =C#%> 





并且global.asax.cs因此将被命名为:



  namespace  WebApplication1 
{
public class 全局:HttpApplication
{
}
}


Hi , when i create Global.asax.cs page then what will be the namespace ....

the case,

in global.asax.cs page

namespace ---------
{
public class Global : System.Web.HttpApplication
{

protected void Application_Start(object sender, EventArgs e)

in this case i could not understand that why we use code behind Global.asax.cs page ....

解决方案

Normally, global.asax would reference the Global class in the namespace of your project, like so:

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



And global.asax.cs would be thus namespaced:

namespace WebApplication1
{
    public class Global : HttpApplication
    {
    }
}


这篇关于当我创建Global.Asax.Cs页面时,什么是命名空间.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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