Global.asax and CodeFile

  • Thread starter Michael Tissington
  • Start date
M

Michael Tissington

How do I specify the CodeFile for my Global.asax file ?

According to the documentation I can use the CodeFile attribute with
Application, however when I try to use this I get an error saying that it
not a valid attribute.

<%@ Application Language="C#" Inherits="SQLView.Global"
CodeFile="Global.asax.cs"%>
 
K

Kevin Yu [MSFT]

Hi Micheal,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
S

Steven Cheng[MSFT]

Hi Michael,

Welcome.
As for the "not a valid attribute." error, are you getting it in VS2005
designer at design-time rathenr than runtime? As for the ASP.NET 2.0 's
Application Global file, we're recommended not to use codebehind models
since we can direclty put code in asax file, like:
===============
<%@ Application Language="C#" %>
<script runat="server">

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

}

.................................
</script>
=================

So no code behind file needed. Also, when we upgrade an existing asp.net
1.x project to 2.0, the VS2005 IDE will move the codebehind into App_Code
dir and we only reference that class by "Inherits" attribute in asax file
like;

============
<%@ Application Inherits="UCTestWeb.Global" Language="C#" %>

=========


In addition, if you do want to use separate codeFile for Global.asax, it is
still possile, just clear the Global.asax file's content and add both the
correct "Inherits" and "CodeFile" attribute's value, like:

<%@ Application Language="C#" Inherits="UCTestWeb.Global"
CodeFile="Global.asax.cs"%>

The Global.asax.cs file is like:

=============
namespace UCTestWeb
{
public partial class Global : System.Web.HttpApplication
{
................


It can run correctly at runtime no matter whether the IDE will prompt some
error or not....

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Michael Tissington" <[email protected]>
| Subject: Global.asax and CodeFile
| Date: Fri, 2 Dec 2005 11:55:50 -0800
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 65.249.55.7
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362406
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| How do I specify the CodeFile for my Global.asax file ?
|
| According to the documentation I can use the CodeFile attribute with
| Application, however when I try to use this I get an error saying that it
| not a valid attribute.
|
| <%@ Application Language="C#" Inherits="SQLView.Global"
| CodeFile="Global.asax.cs"%>
|
| --
| Michael Tissington
| http://www.oaklodge.com
| http://www.tabtag.com
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top