global-asax

asp.net on session timeout redirect to home page

别等时光非礼了梦想. 提交于 2019-12-06 13:29:41
问题 i have web app and on session timeout and user interaction on the page, this needs to redirect to home/landing page solutions found on the net 1) Session check in page_load of all the aspx pages of the application. 2) code in session start of global.asax public void Session_Start { Response.Redirect("home.aspx"); // or Server.Transfer("home.aspx"); } I am going for 2nd option,let me know 1) whether i am in right way or any better solutions for this? 2) in the second option whether to use

Get names of Online users connected to a Server

[亡魂溺海] 提交于 2019-12-06 13:13:48
I am new to asp.net. I have gone through this link which has shown how to count the online users connected to a server using asp.net. ( which is working when I tried ) My question is: What should I change in that code (Global.asax) so that It shows all the names of the connected users instead of counting them. I created a chat application which stores the name of the connected user in a variable chatUsername in js file as shown below: js file var chatUsername = window.prompt("Enter Username:", ""); // chat.client.addMessage = //Function // chat.server.send(chatUsername); .aspx.cs file //Using

redirecting w., ww., wwww. to -> www

一世执手 提交于 2019-12-06 12:59:42
I'm trying to redirect site.com w.site.com ww.site.com and wwww.site.com to www.site.com. My boss wants to ensure typos make it to the site as well. They redirect fine. I'm using ASP.Net and throw a 301 redirect back using a regular expression, however, tools such as http://www.seoconsultants.com/tools/headers.asp don't seem to show a correct redirect when I try to use w.site.com ww. etc. I'm trying to figure out what google sees, but I'm not sure where to check. It would "appear" that firebug reports it as a 301, but I can't figure out why these tools are reporting back the wrong information.

global.asax redirecttoroute not working

我怕爱的太早我们不能终老 提交于 2019-12-06 08:42:55
问题 I want to use a custom route in my global.asax with response.redirecttoroute but it is not working. I have the following in my RouteConfig: routes.MapRoute( name: "Error", url: "Error/{action}/{excep}", defaults: new { action = "Index", excep = UrlParameter.Optional } ); And in my global.asax I do the following: Response.RedirectToRoute("Error", new { action="Index", excep=ex.Message }); In my ErrorController I have: public ActionResult Index(string excep) { ViewBag.Exception = excep; return

store List in Global.asax

耗尽温柔 提交于 2019-12-06 06:22:36
We can store application level strings in a global.asax file like: Global asax: void Application_Start(object sender, EventArgs e) { Application.Lock(); Application["msg"] = ""; Application.UnLock(); } And then in pages we get the "msg" variable as: a.aspx.cs: protected void Page_Load(object sender, EventArgs e) { string msg = (string)Application["msg"]; //manipulating msg.. } However, I want to store List of objects as application level variable instead of string msg. I tried this: Global.asax: void Application_Start(object sender, EventArgs e) { Application.Lock(); List<MyClassName>

Overlapped Recycle and Application_Start

走远了吗. 提交于 2019-12-06 04:21:11
I have an asp.net web app using AppFabric for distributed caching. On Application_Start I initialize my connection to AppFabric. This generally takes milliseconds which is perfectly acceptable. On occasion it can take up to 30 seconds to connect. Prior to a recycle I have a worker process (lets call it wp1). I was under the impression that during a recycle wp1 handled all incoming requests while wp2 was spinning up. I would assume wp2 then becomes responsive when the Application_Start code completes. Based on my logging, this is not the case. It appears that during a recycle wp2 starts

Request is not available in this context -> In Global.asax -> what is replace

这一生的挚爱 提交于 2019-12-06 03:46:19
why the below line has error in global.asax : string RelativeFilePath = "~/" + (AbsoluteFilePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty)).Replace("\\", "/"); Error : Request is not available in this context what is the replacement? thanks in advance If you are hosting your application in IIS7 integrated pipeline HttpContext objects are not available in Application_Start . For your scenario you could do this instead: string relativeFilePath = "~/" + AbsoluteFilePath .Replace(HostingEnvironment.ApplicationPhysicalPath, String.Empty) .Replace("\\", "/"); In IIS7 or

Is it possible to remove information from Server Error pages in ASP.NET 4.0?

岁酱吖の 提交于 2019-12-06 02:14:56
In order to better hide information from users, I'm trying to remove the Version information section from the standard ASP.NET error screen. Custom errors are on, but, under certain circumstances, if you manage to get an error outside of your control (server issues perhaps?) then you can get through to the YSOD. I've tried changing the web.config to include the httpruntime setting where you can set enableVersionHeader to false but the version information still comes through. Also, in the Application_PreSendRequestHeaders method, I've tried to remove "X-AspNet-Version" from the response headers

Application_Start() event in global.asax

烂漫一生 提交于 2019-12-06 01:43:38
问题 Hai guys, My website has thousands of users... I have implemented a background task of sending mails to every user once a day ... I followed this link to do this... http://www.codeproject.com/KB/aspnet/ASPNETService.aspx My question is will Application_Start() will be fired for every user hitting my website... If so every user will be receiving a n number of mails daily so i want to avoid it... 回答1: The Application_Start and Application_End methods are special methods that do not represent

Help debugging - when does the Application_Start run in global.asax file?

♀尐吖头ヾ 提交于 2019-12-05 22:40:20
Here's the snippet from my Global.asax: <script runat="server"> void Application_Start(object sender, EventArgs e) { // log this call EventLogger.Log("ApplicationStart"); } void Application_BeginRequest(object sender, EventArgs e) { // log what the user is doing UsageLogger.Log(UsageLogger.GetServerVariables()); } </script> When I open the log, I see many ApplicationStart calls interspersed with usage calls. Why does my application seem to restart so much? rick schott Application_Start fires once when the app starts up. Application_BeginRequest happens on every request. This link helped in a