Web Forms :: Access Class / Import Namespace In Global.asax

May 31, 2010

I have added global.asax file in my webservice project. in webservice project i have one class file name as 'Class1.vb' in this class contain some methods() , i want to access those methods from 'class1.vb' in global.asax.vb file. any body knows how to access those methods in global.asax.vb. file

View 5 Replies


Similar Messages:

Class In App_Code Not Accessible By Global.asax.cs Error - Namespace Name 'MyClass' Could Not Be Found

Nov 18, 2010

I've created a new class in App_Code

namespace Site {
public class MyClass {
public MyClass() {
}
}
}

this is my Global.asax.cs

[code]....

The error is in: MyClass myClass = new MyClass();

The type or namespace name 'MyClass' could not be found (are you missing a using directive or an assembly reference?)

View 1 Replies

Web Forms :: How To Access Session Variable In Global.asax File

Mar 10, 2011

I am have declared a session variable in login page of my application. I want to access that session variable in Application_BeginRequest of global.asax file. But I am not able to do it. Could you please suggest how to access the session variable in my global.asax file

void Application_BeginRequest(Object sender, EventArgs args)
{
string language = HttpContext.Current.Application["language"].ToString();
}

View 2 Replies

Way To Override And Inherit Default HttpApplication Class From Global.asax

Oct 19, 2010

am currently working on a web application, whereby I want to add code to the Application_BeginRequest method of the Global.asax file, without adding code to the Global.asax file, which sounds a little crazy, let me explain a bit more.If anyone has ever developed in sitecore before, they would have seen that the Global.asax file has empty methods, however it has 'using Sitecore;' and the global.asax file provided does not inherit from System.Web.HttpApplication.

View 1 Replies

Access Global.asax Static Members?

Dec 30, 2010

If we declare a static variable in Global.asax then how to access it inside an ASP.NET page ?

<script runat=server">
public static object myObject = new MyClass();
// Application_Start() and other stuff goes here.
</script>

And, is this a good idea for storing a global object (same instance for all requests) ?

View 3 Replies

State Management :: Want To Access Url In Application_start Event In Global.asax?

Dec 1, 2010

Suppose my website address is like http://localhost/MyWebsite

I wanted to access this url in Application_start event in global.asax, Can i some how get it?

[I know i can get it via application_beginrequest or other event]

View 17 Replies

Web Forms :: How To Access A Webform Control From Another External Class / Namespace

Sep 24, 2010

Currently, I have many controls and objects such as Chart1 of mschart as part of the public partial class _Default : System.Web.UI.Page.

At the bottom, I've created a second class that is not part of the _Default webform class. How can I access the webform controls from this second class?

For example, I want to do

Chart1.Series["Series1"].Points.AddXY((pointIndex + 1) * 40, datapoints[pointIndex]);

I want to pass pointIndex integer and the datapoints array.

I know that Chart1 was created protected global access modifier in the designer.cs but when I changed it to public, it still had a problem.

View 7 Replies

C# - Dictionary Lookup Efficiency & Request Scoped Global Variable Accessible By Global.asax And Pages/etc?

Feb 8, 2011

I know there is a couple answered questions on here regarding "request scoped" globals, but I want to nit-pick on something specifically and maybe squeeze some extra enlightenment out of one or two of you.I have an ASP.NET C# Website and a static Dictionary of objects (loaded from DB once on Application start). Each page request will need to do a lookup in the Dictionary (based on a key derived from the request url/etc) and get the appropriate object.The issue is I'm trying to maximize efficiency by reducing the lookups to the Dictionary per Request. Doing just a single lookup within a Page itself is easy enough and I can pass the object to sub controls, etc too.. but global.asax is separate from the Page and it also needs to use the object (in Application_BeginRequest and Session_Start).

So is doing a Dictionary lookup once in Application_BeginRequest, once (when necessary) in Session_Start and once in the Page negligible speed wise, even if there are many requests coming in every second?I would like it if I could just have a Request scoped global variable that I can easily call upon.. the only one I see available though is HttpContext.Current.Items and that is a Dictionary itself.Am I beingridiculously nit-picky with my concern over efficiency? or will these milliseconds (nanoseconds?) get me in the long run when more and more requests are being made?

PS. I currently only have around 100 objects in the Dictionary although this may increase in the future.

View 2 Replies

How To Access Public Global.asx.cs Property From A Business Class

Feb 2, 2011

I have a property on my Global.asax.cs class that I need to access from a business class, i.e. using HttpContext.Current. How do I do this? Global.asax.cs (in a web project)

public partial class Global : System.Web.HttpApplication
{
public static ProxyGenerator Generator = new ProxyGenerator();
Business class (in a separate business project)
var generator = ((Sei.Osp.Web.Global)HttpContext.Current.ApplicationInstance)

This obviously doesn't work and I don't want to reference the whole web project in the business project as it will create a circular reference (the business project is already referenced in the web project)

UPDATE:

To clarify - the property I'm creating holds an instance of the Castle Dynamic Proxy Generator class. I've read that you shouldn't just create this all over the place. So I thought I'd create it in my Global.asax.cs and then just use that instance wherever I need to create a proxy class (I'm using it to do AOP) Is there a better way of doing this?

View 2 Replies

Web Forms :: What Is Global.asax / How To Use It

Jan 27, 2010

I want to make All Methods about Error handling in asp.net some one device me at using global.asax what is global.asax?

how can i use it ?

View 1 Replies

Web Forms :: Using Enums In Global.asax>?

May 4, 2010

I was given a web app written in VB.net. I am using VS2008. The project has a Global.asax page with Enums declared

Example:Public Enum eCurrentLoc as Integer

Admins

AdminTools

Home

LogIn

Status

End Enum

But in the web application itself I get errors on this line of code:

Ads = Global.eCurrentLoc.Admins

I get the blue scwigly line under Global.eCurrentLoc

The error states 'eCurrentLoc' is not a memeber of '<Defaults>'

View 1 Replies

Web Forms :: Function In Global.asax Is Not Running?

Sep 7, 2010

I am using a Global.asax in on my webpage to run a function with an interval. In this test I have set the interval to 1 minute to be able to see what happens.

I have declared a timer in the Application Start which should mean that when I open up the webpage after I have uploaded the Global.asax the timer will start.

However with this code below where I try to create a file named newFile.txt, this file is not created. I cant really understand what I could be missing. It seems that the function is not running ?

[Code]....

View 12 Replies

Web Forms :: Global Asax.cs Code Is Not Executing?

Jul 22, 2010

I have a Global.Asax and Global.Asax.cs file that is specific to my particular Asp.net project. For some unknown reason the code in my Global.asax.cs file is not being executed. I thought that the breakpoints were being ignored, however that is not the case. Because if I try to deliberately force an error to occur, the code is never executed. Below is an example of what I am talking about. The real code in my Application_Start method is not shown below. ANd other methods are not shown as well.

I have tried renaming the Global.asax file and then re-creating it, and that did not work either. Strange because when I try and create a new Global.asax file, the option to create a code behind file is greyed out.

Why isn't my Global.Asax.cs code being executed?

private void Application_Start(object sender, EventArgs e)
{
int x = 1;
int y = 1;
int z=1/(x-y)
}

View 8 Replies

Web Forms :: Global File Is Ambiguous In The Namespace?

Aug 23, 2010

I just added a global file to my web application and now I am getting this message.

Error 3 'global_asax' is ambiguous in the namespace 'ASP'. C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET FilesmyFile759a71c4f17a867App_global.asax.sfac6plp.1.vb 31

Here is the code in he Global file:

[Code]....

[Code]....

View 2 Replies

Web Forms :: Global.asax Doesn't Work - Procedure?

Apr 19, 2010

Global.asax
void Application_Error(object sender, EventArgs e)
{
Exception err = Server.GetLastError();
Session["error"] = err.InnerException.Message;
}
web.config
<customErrors mode="On" defaultRedirect="CustomerPage.aspx"></customErrors>
CustomerPage.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Session["error"] != null)
{
Response.Write(Session["error"].ToString());
}

It does not work. How to call a procedure?

View 1 Replies

Web Forms :: Global.asax - Reset To Its Initial Value Every Hour

Dec 17, 2010

my Global.asax file looks like this -

[Code....]

From some reason that I am not aware of Application("vCounter") reset to its initial value (0) every hour (i think).

View 1 Replies

C# - Session_End In Global.asax.cs Not Firing Using Forms Authentication?

Dec 15, 2010

I have an asp.net 4.0 application that is using forms authentication set to a timeout at 45 minutes. I would like to redirect the user to a timeout page when the session has expired. Can anyone tell me how to do this? I am running .net 4.0.

web.config has:

<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="~/Login.aspx"
defaultUrl="~/Default.aspx" protection="All" timeout="45"
requireSSL="false">
</forms>
</authentication>

Global.asax.cs file has:

void Session_End(object sender, EventArgs e)
{
Response.Redirect("~/Timeout.aspx");
}

View 2 Replies

Web Forms :: What Does Initialize() Does In Application_Start Method In Global.asax

Aug 13, 2010

In my company app they are doing the following. I do not understand that what initialize does? Do we need to Initialize assemblies before using them? and what kind of assemblies needs to be initialized?

Below is the code:

[code]....

View 2 Replies

Web Forms :: How To Purposely Raise An Application_Error In Global.asax

Nov 14, 2010

Just for kicks, how do you say, wire up an ASP button to purposely throw an Application_Error exception in the global.asax file?

lets say you wanted to test the functionality of the error handling and what is doing..and you don't have a real error to do it. what is the easiest way just raise this event?

View 4 Replies

Web Forms :: How To Check Any Form Element Value In Global.asax

Oct 5, 2010

I am redirecting user from http to https if page is not secure from global.asax file in application_Begin event

But there are some pages in which i don't want to redirect to https page. I want to detect any form element which will tell me weather page should be secured or not. but when i check Requet.Form[_Viewstate] it gives me null value. Right now i check like Request.PhysicalPath.ToLower().IndexOf("test.aspx") ==-1 && !page.IsSecureConnection-> redirect to secure page but in future there will be more page which should be on http.

Is there any general way to redirect to https if page i added any hidden field on page "hfIsHttps=1" and detect that element if 1 then go other wise don't go Following is my code global.asax in application_Begin event

[code]....

I want, instead of hard core check for perticular page there should be general way, like each page itself should tell weather it should be for http or https

View 1 Replies

Web Forms :: Reference Global.asax Variable In Page?

Apr 27, 2010

I have a ASP.NET/C# web application. There is an object instantiated in the Global.asax that I'll call g_objVariable. What I would like to do is reference one of it's properties in the ASP.NET page itself, like this.

The g_objVariable's Prop1 value is: <%=AppNameSpace.Global.g_objVariable.Prop1.ToString()%>

I get it to see the reference, but it keeps telling me that due to it's protection level I can't access it. I have it set to 'internal static'. What would be the least level I could set it to, but still allow the page to access it?

View 3 Replies

Web Forms :: Hit Counter(i Need Idea)in Global.asax Page?

Sep 23, 2010

My website needs hit counter. i have created hit count in global.asax page, which works fine. Now i wanted to display hit count in all pages. so, do i have to use mater page or function to all in every page.

View 3 Replies

Web Forms :: Save Value In Session - Call Method On Global.asax

Aug 18, 2010

I have a method in one class file with defination like this which gets the user id of logged person.

public string GetUserID(HttpRequest req)
{ .... }

I need to call this method in global.asax and save that value in session. I need to use this session value i need to use this Session value and assign that to label in Masterpage. I did not use global.asax before. And what should be the input to method... i have seen only Request is have the returntype HttpRequest. So i thought of giving that.

View 1 Replies

Web Forms :: Global.asax - Method Not Executed When Browser Closes

Dec 28, 2010

[Code]....

i am trying to do this is Global.asax file. but this method is not executed when the browser closes. or am i doing something wrong?

View 6 Replies

Web Forms :: Global.asax Application_BeginRequest Doesn't Work On Server?

Jun 11, 2010

I want to protect one file in a subdirectory with Global.asax. (I know that this isn't the conventional way of going about this) but it works on my computer and not on the server.I have a global.asax file in my root dir and Application_BeginRequest checks if the user is requesting a particular file. If they are logged in, it allows access. If they are not logged in they are redirected to the default page.My problem is this: My code works on my personal computer but does not work on the server. Do I have to configure a setting in the web.config or adjust something on the server? Code:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim fullOrigionalpath As String = Request.Url.ToString.ToLower
'PROTECTED FILE
If fullOrigionalpath.Contains("/uploads/groups.xls") Then
If HttpContext.Current.User.Identity.IsAuthenticated = False Then Response.Redirect("~/login.aspx")
End If
End Sub

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved