|
I'm absolutely sure that the SP is correct bc when I have the content of the content of MyRefresh() in the Page_Load it works without any problems.
But when I moved the code to MyRefresh() and call it from Page_Load it doesn't work
Sub Page_Load()
If Not Page.IsPostBack Then
Refresh()
End If
End Sub
|
|
|
|
|
Well, based on the code you posted the only difference I can see is in the new code you are checking If Not Page.IsPostback
This seems like the correct thing to do, but it doesn't seem you did that when you weren't using the MyRefresh() method. So I guess you could try removing that and see if it works. I still think you should be able to step through the program and see if the code is getting called correctly.
Ben
|
|
|
|
|
If Not Page.IsPostback has no effect...but I think I found something.
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
SQLconn.Open()
Dim SelectCmd1 As New SqlCommand("SP1", SQLconn)
SelectCmd1.CommandType = CommandType.StoredProcedure
Dim result1 As Integer
Dim myDataReader1 As SqlDataReader
myDataReader1 = SelectCmd1.ExecuteReader()
myDataReader1.Read()
result1 = myDataReader1.GetInt32(0)
SQLconn.Close()
ChangeButton1(result1)
End Sub
"Handles MyBase.Load" is the key....when I remove this I have the same as in the MyRefresh().
I had to modified it like this:
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Refresh()
End If
End Sub
Sub Refresh()
SQLconn.Open()
Dim SelectCmd1 As New SqlCommand("SP1", SQLconn)
SelectCmd1.CommandType = CommandType.StoredProcedure
Dim result1 As Integer
Dim myDataReader1 As SqlDataReader
myDataReader1 = SelectCmd1.ExecuteReader()
myDataReader1.Read()
result1 = myDataReader1.GetInt32(0)
SQLconn.Close()
ChangeButton1(result1)
End Sub
Why is Handles MyBase.Load so important???
|
|
|
|
|
Without it your load event doesn't fire. That is how your code behind methods get linked into events. Glad you figured it out.
Ben
|
|
|
|
|
Thank you..
but I haven't finished yet..
|
|
|
|
|
Hi,
This has got me really baffled. When I run Dim url As String = HttpContext.Current.Request.Url.AbsolutePath.ToLower from Application_beginRequest in Global.asax with server that ships with Visual Web Developer everything works as expected.
However, today when I tried to move all code onto IIS server this just doesn't return the same URL!
On localhost (Visual Web Developer), variable url is /sandbox/my/home/page, but on IIS it returns /sandbox/index.aspx.
Yes, this is another HttpContext.RewritePath application which is why I need to know what the user types as a URL event though a 404 error is expected.
Anyone have any idea why the url would be different, or know of anything I could possibly be doing wrong?
Any help is greatly appreciated.
Thanks,
Jason.
|
|
|
|
|
This is just a guess, but with VS you are telling it what page to start on. With IIS when you enter the url it uses your IIS settings to figure out what the default page should be. index.aspx sounds like the default page you set up in IIS. So if you want a call to the basic url to go to a different default page you need to change it in IIS manager.
Hope that helps.
Ben
|
|
|
|
|
Ben,
Thank you for the prompt reply. I have enabled the default content page in IIS and it's pointing to index.aspx. I do want the default page to be index.aspx.
The thing is, I've designed user friendly urls but they won't work because IIS is trying to go directly to them but they are virtual, so they don't exist. I'm using HttpContext.RewritePath to rewrite the urls.
Jason.
|
|
|
|
|
So if the user types in the base url with no page, it will go to your default page. So what is your problem? I have done much RewritePath stuff, but I have done some http handler stuff. Are you sure your handler is set up correctly so that it is getting called?
Ben
|
|
|
|
|
I think you might be misunderstanding my problem. Let's say my root directory has only the following files:
* index.aspx
* web.config
* global.asax
When the user visits, for example: http://www.mysite.com/tutorials/tute/1
The global.asax file should be able to grab this URL using HttpContext.Current.Request.Url.AbsolutePath.ToLower method and I will use this string to formulate a RewritePath to index.aspx?a=tutorials&tute=1.
As you can see, the directories tutorials, tute and 01 don't exist, so there is no index.aspx file to refer to.
My problem is, IIS and HttpContext.AbsolutePath isn't giving me http://www.mysite.com/tutorials/tute/1 or any of the variables. But the strange thing is, this is all working on localhost.
So it makes me wonder if it's something to do with IIS, or if there is another way to get the typed URL.
Jason.
|
|
|
|
|
Well, if IIS is trying to correct the url and re-direct it to your default page, then you there is probably only one thing you can do. Turn off the default page in IIS and then you will have to write an http handler module for the 404 and properly redirect them. At least that is what I would try to do.
Ben
|
|
|
|
|
Thanks for the suggestions Ben, but I can't turn off the default pages because I can't guarantee every visitor will use http://www.mysite.com/tutorials/tute/1, they may access via http://www.mysite.com.
Also, doesn't Application_beginRequest execute before it delivers a page? I have code that works (and I know it does because I've tried hard coding a string in place of the return value of HttpContext.Current.Request.Url.AbsolutePath.ToLower and tested on IIS), I just need to get the URL of page before IIS decides to throw a 404.
Ugh, what's going on with IIS?!
-.-..
Jason
|
|
|
|
|
There must be something going on with your setup. I just tried one of my site putting in a virtual dir that doesn't exist and I get the 404 message. So, do you have an error page set up? Or something like that? According to MS help:
The following events are executed by the HttpApplication class while the request is processed. The events are of particular interest to developers who want to extend the HttpApplication class.
Validate the request, which examines the information sent by the browser and determines whether it contains potentially malicious markup. For more information, see ValidateRequest and Script Exploits Overview.
Perform URL mapping, if any URLs have been configured in the UrlMappingsSection section of the Web.config file.
Raise the BeginRequest event.
Raise the AuthenticateRequest event.
Raise the PostAuthenticateRequest event.
Raise the AuthorizeRequest event.
Raise the PostAuthorizeRequest event.
Raise the ResolveRequestCache event.
Raise the PostResolveRequestCache event.
Based on the file name extension of the requested resource (mapped in the application's configuration file), select a class that implements IHttpHandler to process the request. If the request is for an object (page) derived from the Page class and the page needs to be compiled, ASP.NET compiles the page before creating an instance of it.
Raise the PostMapRequestHandler event.
Raise the AcquireRequestState event.
Raise the PostAcquireRequestState event.
Raise the PreRequestHandlerExecute event.
Call the ProcessRequest method (or the asynchronous version BeginProcessRequest) of the appropriate IHttpHandler class for the request. For example, if the request is for a page, the current page instance handles the request.
Raise the PostRequestHandlerExecute event.
Raise the ReleaseRequestState event.
Raise the PostReleaseRequestState event.
Perform response filtering if the Filter property is defined.
Raise the UpdateRequestCache event.
Raise the PostUpdateRequestCache event.
Raise the EndRequest event.
Anyway, don't know if that helps or not.
Ben
|
|
|
|
|
Err.. not really, I don't understand IIS well enough or to that level.
Thanks anyway.
Jason
|
|
|
|
|
Here is some more MS help:
Raised at the appropriate time in the application life cycle, as listed in the application life cycle table earlier in this topic.
Application_Error can be raised at any phase in the application life cycle.
Application_EndRequest is the only event that is guaranteed to be raised in every request, because a request can be short-circuited. For example, if two modules handle the Application_BeginRequest event and the first one throws an exception, the Application_BeginRequest event will not be called for the second module. However, the Application_EndRequest method is always called to allow the application to clean up resources.
So if you do have an error handling page it might be causing the problem.
Ben
|
|
|
|
|
I do have a dud error handling page, but did not originally; and it still wasn't working.
I only added it because I was desperate and tried this.
"On IIS 6.0 change 404 default page to /404.aspx and the type to "URL"."
Jason
|
|
|
|
|
Ok, so after countless hours of head scratching, it seems that my problem is to do with the setup of IIS.
The web server that ships with Visual Web Developer seems to run Application_beginRequest before calling a 404 Error, but IIS is calling a 404 Error before the Application_beginRequest.
Why would this be the case? How can I change it so it calls Application_beginRequest before calling a 404 Error?
I don't know if it's because my .net2 application is a sub directory of a .net1 website? The application has been added to a separate .net2 application pool then the .net1 website. Everything seems to work except for the url rewriting.
Please help!
Jason.
|
|
|
|
|
I want maintain log of webpages visited for individual user how it is possible in asp.net 2.0.
Can anyone help me.
GIRISH
|
|
|
|
|
|
Hi,
I am migrating a .net 1.1 application to .net 2.0 and get the following error:
"Metadata file 'dll_name' could not be found". The project has the reference to the project that it´s missing so I cannot really figure out why it is this way. Anyone who has any experience/solution with this?
Build order?
thanx in advance!
Regards
/Christoffer
|
|
|
|
|
Hi ALL
i am developing a web application in which i have created service which will indexed all microsoft office type files. All things are working fine except service is taking 80 MB (As shown by task Manager) space in memory.
So my questions are
1) What you think do i need to worry about memory space ? or it is normal
2) is there any memory leak in the application ? How to check that ?
Note :- i checked i am closing all the objects which are opened but not sure those are garbage collected or not
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Standard profilers should be able to throw more light on this too.
|
|
|
|
|
Check this MSDN Article[^] regarding memory leakage. Or as Vasudevan Deepak Kumar told go with some profilers. You can try ANTS profiler[^]. I think it's good.
|
|
|
|
|
Thanks for reply
i already install ANTS profiler but not getting where memory is leaked
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
i have some text in textbox1.when i change data of tht text box at run time
text change event has to be fired.how to do tht(text change has to be fired ewithout pressing enter or tab key)n i cant use javascript for this.any other solution???
actually i want to enetr text in gridview when button is clicked(for tht row)i get pop up window with some text.so for tht i m taking text box outside tht grid n passing value of tht textbox to grid cell. any other way to do this??
|
|
|
|