By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,954 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,954 IT Pros & Developers. It's quick & easy.

Running code when viewing aspx code

P: n/a
Hi guys,

Our team has a very strange problem. I hope anybody can help.

We have a class called webpage and all our aspx-pages bases on it. Then we
have a SYS.IO.File Class which have a function. This function checks the hash
value of some ini-files. If the hash value is not valid then the function
throws an error.
Imagine we are editing the code behind file of an aspx-page. If we now want
to view the aspx-code we double click the aspx-file in the project explorer
and then there occurs the exception of the function in the class SYS.IO.File.
The application is not running.
We don't have any idea why the webpage is calling the function in this moment.
Is there any possible reason why code is running when viewing the aspx-code
while the web-application is not running?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Assuming that you are working with VS.NET

If you open any aspx file in VS.NET by double clicking in Solution Explorer,
VS will open
that page in design mode, As per my understanding the design view is nothing
but
like a web browser, so it executes the code there and shows the error.

I too have faced some strange errors when opening a aspx page in design view
you can change this options in tools>options window to open any aspx page
in html view.

Have a try, as i'm not sure about this answer.
Atleast it will help you in going closer towards the problem.

--
Vadivel Kumar
http:\\charpblogs.blogspot.com

"Matthias H." <Ma*******@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
Hi guys,

Our team has a very strange problem. I hope anybody can help.

We have a class called webpage and all our aspx-pages bases on it. Then we
have a SYS.IO.File Class which have a function. This function checks the
hash
value of some ini-files. If the hash value is not valid then the function
throws an error.
Imagine we are editing the code behind file of an aspx-page. If we now
want
to view the aspx-code we double click the aspx-file in the project
explorer
and then there occurs the exception of the function in the class
SYS.IO.File.
The application is not running.
We don't have any idea why the webpage is calling the function in this
moment.
Is there any possible reason why code is running when viewing the
aspx-code
while the web-application is not running?

Nov 19 '05 #2

P: n/a
Hi Matthias,

the reason why your code is executed is that VS.NET calls OnInit method of
the page (but not only, also code in properties is executed...), when you
try to open the aspx in Desing Mode.

There is a workaround.

You need to put your code inside this IF:
if (Site == null || !Site.DesignMode)
{
// this is the normal situation
}
else
{
// this is the VS.NET DesingMode situation
}

HTH

Bye,
Stefano
"Matthias H." <Ma*******@discussions.microsoft.com> ha scritto nel messaggio
news:25**********************************@microsof t.com...
Hi guys,

Our team has a very strange problem. I hope anybody can help.

We have a class called webpage and all our aspx-pages bases on it. Then we
have a SYS.IO.File Class which have a function. This function checks the hash value of some ini-files. If the hash value is not valid then the function
throws an error.
Imagine we are editing the code behind file of an aspx-page. If we now want to view the aspx-code we double click the aspx-file in the project explorer and then there occurs the exception of the function in the class SYS.IO.File. The application is not running.
We don't have any idea why the webpage is calling the function in this moment. Is there any possible reason why code is running when viewing the aspx-code while the web-application is not running?

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.