Showing posts with label time. Show all posts
Showing posts with label time. Show all posts

Thursday, March 29, 2012

performance of code

Is there someway to profile your code in Visual Studio with reagard to performance, meaning, to see the time elapse per code that is crunching behind the scenes? I have an application that seems to slow way down at a certain page but I really have no idea where it is hanging up?

Thanks in advance,

Eric

I havent found anything that tests for complexity, calculating the McCabe factor etc.. like there is in C++ and fortran or Delphi.

However here is a link that does have a freeware program you can download to test performance

http://www.alessandropulvirenti.it/programmazione/ for c# and VB


You can enable Tracing on your page (just add Trace="true" to the page directive of your aspx page), and then use Trace.Write(DateTime.Now); to determine what time different sections of code are executed.


Hi Eric,

Based on my understanding, you want to know how to analyze your application performance. If I have misunderstood you, please feel free to let me know.

To better understand your question, could you please confirm the following information:
What version of Visual Studio are you using? If you use Visual Studio 2005 Team Edition, you can use Performance tools which be integrated with development environment (IDE) to measure, evaluate, and target performance-related issues in your code. For more information, see Analyzing Application Performance.


I hope this helps.


Tracing is very clumsy and awkward to set up and leaves you with swathes of code to remove once you've sorted the problems out.

Consider using something like this:

http://www.red-gate.com/products/ants_profiler/


you can get some pretty good results fromhttp://www.jetbrains.com/profiler/

They offer a 10 day trial.

Performance questions

Hi;

Got a couple of performance questions.

1) My app is pre-compiled but when I bounce IIS and then go to a page for
the first time, it takes a couple of seconds to get that page. Subsequent
hits are fast. Why?

2) Even after hitting all pages involved, if I logout and then go to login
again - it takes 5 - 10 seconds. The login page uses the standard login
control and the ASP.NET membership classes so it's not my code at all. Any
ideas why it's slow?

3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
using System.Diagnostics.Trace. This does not show up in the trace.axd
details at all. How can I get that in there too?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htmHi Dave,

Regarding on the question you mentioned, here are some of my understanding:

1) My app is pre-compiled but when I bounce IIS and then go to a page for
the first time, it takes a couple of seconds to get that page. Subsequent
hits are fast. Why?
==========================
How did you precompile your web application, full mode(non-updatable) or
partial mode(updatable)? For partial precompile, the ASP.NET runtime still
need to do a slim precompile to merge the aspx and the class in the
pregenerated assembly. Also, even if you fully precompile the site, you
should still take the JIT compile into account.

2) Even after hitting all pages involved, if I logout and then go to login
again - it takes 5 - 10 seconds. The login page uses the standard login
control and the ASP.NET membership classes so it's not my code at all. Any
ideas why it's slow?
==============================
This seems a bit unexpected. Can you repro the behavior through a very
simple forms authentication secured web project?

3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
using System.Diagnostics.Trace. This does not show up in the trace.axd
details at all. How can I get that in there too?
============================

..NET framework 2.0 does provide means for you to do redirection between
"Diagnostics Trace" and ASP.NET Trace. Here is a good web article mentioned
the steps to do so:

#Tracing Enhancements in ASP.NET 2.0
http://www.extremeexperts.com/Net/A...sinASPNET2.aspx
Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Hi;

1) I use WebDeployment and have it set to "NOT allow to be updatable",
"merge all pages and control outputs to a single assembly", APTCA. Should
this take time to run the first time? And if so, is there a way in IIS to
tell it to load and JIT compile everything?

2) I will try to create a sample.

3) perfect - thanks

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Steven Cheng[MSFT]" wrote:

Quote:

Originally Posted by

Hi Dave,
>
Regarding on the question you mentioned, here are some of my understanding:
>
1) My app is pre-compiled but when I bounce IIS and then go to a page for
the first time, it takes a couple of seconds to get that page. Subsequent
hits are fast. Why?
==========================
How did you precompile your web application, full mode(non-updatable) or
partial mode(updatable)? For partial precompile, the ASP.NET runtime still
need to do a slim precompile to merge the aspx and the class in the
pregenerated assembly. Also, even if you fully precompile the site, you
should still take the JIT compile into account.
>
>
2) Even after hitting all pages involved, if I logout and then go to login
again - it takes 5 - 10 seconds. The login page uses the standard login
control and the ASP.NET membership classes so it's not my code at all. Any
ideas why it's slow?
==============================
This seems a bit unexpected. Can you repro the behavior through a very
simple forms authentication secured web project?
>
>
>
3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
using System.Diagnostics.Trace. This does not show up in the trace.axd
details at all. How can I get that in there too?
============================
>
.NET framework 2.0 does provide means for you to do redirection between
"Diagnostics Trace" and ASP.NET Trace. Here is a good web article mentioned
the steps to do so:
>
#Tracing Enhancements in ASP.NET 2.0
http://www.extremeexperts.com/Net/A...sinASPNET2.aspx
>
Hope this helps.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
>
==================================================
>
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.
>
>
>
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.
>
==================================================
>
>
>
This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>
>
>
>


Thanks for your reply Dave,

there is no built-in means to make the entire ASP.NET site JIT compiled,
you may need to programmatically visit all those pages so as to make them
JIT compiled. For the "merge all pages and control outputs to a single
assembly", I dont think this is the cause of the slow performance.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Dave,

Any further progress on this issue? Please feel free to post here if there
is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Performance questions

Hi;
Got a couple of performance questions.
1) My app is pre-compiled but when I bounce IIS and then go to a page for
the first time, it takes a couple of seconds to get that page. Subsequent
hits are fast. Why?
2) Even after hitting all pages involved, if I logout and then go to login
again - it takes 5 - 10 seconds. The login page uses the standard login
control and the ASP.NET membership classes so it's not my code at all. Any
ideas why it's slow?
3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
using System.Diagnostics.Trace. This does not show up in the trace.axd
details at all. How can I get that in there too?
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htmHi Dave,
Regarding on the question you mentioned, here are some of my understanding:
1) My app is pre-compiled but when I bounce IIS and then go to a page for
the first time, it takes a couple of seconds to get that page. Subsequent
hits are fast. Why?
==========================
How did you precompile your web application, full mode(non-updatable) or
partial mode(updatable)? For partial precompile, the ASP.NET runtime still
need to do a slim precompile to merge the aspx and the class in the
pregenerated assembly. Also, even if you fully precompile the site, you
should still take the JIT compile into account.
2) Even after hitting all pages involved, if I logout and then go to login
again - it takes 5 - 10 seconds. The login page uses the standard login
control and the ASP.NET membership classes so it's not my code at all. Any
ideas why it's slow?
==============================
This seems a bit unexpected. Can you repro the behavior through a very
simple forms authentication secured web project?
3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
using System.Diagnostics.Trace. This does not show up in the trace.axd
details at all. How can I get that in there too?
============================
NET framework 2.0 does provide means for you to do redirection between
"Diagnostics Trace" and ASP.NET Trace. Here is a good web article mentioned
the steps to do so:
#Tracing Enhancements in ASP.NET 2.0
http://www.extremeexperts.com/Net/A...sinASPNET2.aspx
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
========================================
==========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi;
1) I use WebDeployment and have it set to "NOT allow to be updatable",
"merge all pages and control outputs to a single assembly", APTCA. Should
this take time to run the first time? And if so, is there a way in IIS to
tell it to load and JIT compile everything?
2) I will try to create a sample.
3) perfect - thanks
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Steven Cheng[MSFT]" wrote:

> Hi Dave,
> Regarding on the question you mentioned, here are some of my understanding
:
> 1) My app is pre-compiled but when I bounce IIS and then go to a page for
> the first time, it takes a couple of seconds to get that page. Subsequent
> hits are fast. Why?
> ==========================
> How did you precompile your web application, full mode(non-updatable) or
> partial mode(updatable)? For partial precompile, the ASP.NET runtime still
> need to do a slim precompile to merge the aspx and the class in the
> pregenerated assembly. Also, even if you fully precompile the site, you
> should still take the JIT compile into account.
>
> 2) Even after hitting all pages involved, if I logout and then go to login
> again - it takes 5 - 10 seconds. The login page uses the standard login
> control and the ASP.NET membership classes so it's not my code at all. Any
> ideas why it's slow?
> ==============================
> This seems a bit unexpected. Can you repro the behavior through a very
> simple forms authentication secured web project?
>
> 3) I put Trace.Write("enter FindAllGlobal"); in my non ASP code so it's
> using System.Diagnostics.Trace. This does not show up in the trace.axd
> details at all. How can I get that in there too?
> ============================
> .NET framework 2.0 does provide means for you to do redirection between
> "Diagnostics Trace" and ASP.NET Trace. Here is a good web article mentione
d
> the steps to do so:
> #Tracing Enhancements in ASP.NET 2.0
> l]
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> [url]http://msdn.microsoft.com/subscriptions/support/default.aspx." target="_blank">http://www.extremeexperts.com/Net/A...t/default.aspx.
> ========================================
==========
>
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
>
>
>
>
Thanks for your reply Dave,
there is no built-in means to make the entire ASP.NET site JIT compiled,
you may need to programmatically visit all those pages so as to make them
JIT compiled. For the "merge all pages and control outputs to a single
assembly", I dont think this is the cause of the slow performance.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Dave,
Any further progress on this issue? Please feel free to post here if there
is anything else we can help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Monday, March 26, 2012

PerformanceCounter / System Up Time / TimeSpan

Hi all,
I'm having a bit of trouble with the following function...
Private Function GetSystemUpTime() As TimeSpan
' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter
' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")
' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
' return result
Return Result
End Function
For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...
Can anyone shed any light on this for me...
PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.
Regards
RobThe first call always returns zero, apparently... see the page here:
http://www.sitepoint.com/forums/pri...ad.php?t=376778
Regards,
Brett.
Rob Meade wrote:
> Hi all,
> I'm having a bit of trouble with the following function...
> Private Function GetSystemUpTime() As TimeSpan
> ' declare variables
> Dim Result As TimeSpan
> Dim PerformanceCounter As PerformanceCounter
> ' create new instances of our objects
> PerformanceCounter = New PerformanceCounter("System", "System Up Time"
)
> ' populate
> Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
> ' return result
> Return Result
> End Function
> For some reason I keep getting the value 0 (zero) for days, hours,minutes,
> seconds etc - ie, I've tried this on 2 machines now and the result is alwa
ys
> the same. I've tried other counters using a similar method (for available
> memory,application restarts etc) and they do come through...
> Can anyone shed any light on this for me...
> PS: I've had a bit of a look online and I'm aware of the environment.tick
> thing but that has a problem over a value of 24 (goes to minus numbers) so
> would prefer to use a PerformanceCounter object.
> Regards
> Rob
"Brett Wiltshire" wrote ...

> The first call always returns zero, apparently... see the page here:
> http://www.sitepoint.com/forums/pri...ad.php?t=376778
Hi Bretty,
Thanks for your reply - you know - in the example I saw that had this code
it actually said about that - I assumed - clearly wrongly - that the
"NextValue()" thing meant - go get the next one because the first one is
always zero...
*sigh*
That's taken up 2 hours of my day searching the net just for a
misunderstanding :o(
Anyway, many thanks for your reply - I've for now just duplicated the line
that gets it and it works fine :o)
Thanks
Rob

PerformanceCounter / System Up Time / TimeSpan

Hi all,

I'm having a bit of trouble with the following function...

Private Function GetSystemUpTime() As TimeSpan

' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter

' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")

' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue( ))

' return result
Return Result

End Function

For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...

Can anyone shed any light on this for me...

PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.

Regards

RobThe first call always returns zero, apparently... see the page here:
http://www.sitepoint.com/forums/pri...ad.php?t=376778

Regards,
Brett.

Rob Meade wrote:
> Hi all,
> I'm having a bit of trouble with the following function...
> Private Function GetSystemUpTime() As TimeSpan
> ' declare variables
> Dim Result As TimeSpan
> Dim PerformanceCounter As PerformanceCounter
> ' create new instances of our objects
> PerformanceCounter = New PerformanceCounter("System", "System Up Time")
> ' populate
> Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue( ))
> ' return result
> Return Result
> End Function
> For some reason I keep getting the value 0 (zero) for days, hours,minutes,
> seconds etc - ie, I've tried this on 2 machines now and the result is always
> the same. I've tried other counters using a similar method (for available
> memory,application restarts etc) and they do come through...
> Can anyone shed any light on this for me...
> PS: I've had a bit of a look online and I'm aware of the environment.tick
> thing but that has a problem over a value of 24 (goes to minus numbers) so
> would prefer to use a PerformanceCounter object.
> Regards
> Rob
"Brett Wiltshire" wrote ...

> The first call always returns zero, apparently... see the page here:
> http://www.sitepoint.com/forums/pri...ad.php?t=376778

Hi Bretty,

Thanks for your reply - you know - in the example I saw that had this code
it actually said about that - I assumed - clearly wrongly - that the
"NextValue()" thing meant - go get the next one because the first one is
always zero...

*sigh*

That's taken up 2 hours of my day searching the net just for a
misunderstanding :o(

Anyway, many thanks for your reply - I've for now just duplicated the line
that gets it and it works fine :o)

Thanks

Rob
Anyone know if its possible to pull the same information from different
machines on the network?

A new instance of PerformanceCounter seems to be able to take a machine
name - but I've tried this and get access denied errors...

I guess i some how need to be able to tell the servers in question that the
ASP.Net process model is allowed to access this?

Any ideas anyone?

My other thought was as a web service, so I have one page which drags the
info from the other servers, this would of course then rely on IIS being
present, not so good for my clustered SQL Servers! Open to suggestions...

Regards

Rob

Performing Asynchronous operation

Hi
I have 2 operations to perform one is to upload data and the second is
to generate report. Both take huge time(more than 20 mins and I believe
by that time session would have expired) and hence has to be done
asynchronously.
For uploading data, user will click start button and the asynchronous
operation has to start immediately.
For report generation, user will enter a time when the report has to be
generated(wend date time) and press start button. The asynchronous
operation should start only at this designated time.
How can I do the above 2 operations?
Thanks
rjn
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!You need to read up on threading or use an asynchronous web service for your
first problem. Check out http://www.15seconds.com/issue/031124.htm.
For the second item, you don't say what your system is. If SQL Server, pop
the date and time into a field that can be scanned by a SQL Agent Job every
ten minutes or so. When the record is within ten minutes of the current
time, fire off a stored procedure.
If not SQL, you could achieve something similar using a file and Windows
Scheduler.
"RJN" <rjn@.yahoo.com> wrote in message
news:%23TA15ehrEHA.2000@.tk2msftngp13.phx.gbl...
> Hi
> I have 2 operations to perform one is to upload data and the second is
> to generate report. Both take huge time(more than 20 mins and I believe
> by that time session would have expired) and hence has to be done
> asynchronously.
> For uploading data, user will click start button and the asynchronous
> operation has to start immediately.
> For report generation, user will enter a time when the report has to be
> generated(wend date time) and press start button. The asynchronous
> operation should start only at this designated time.
> How can I do the above 2 operations?
> Thanks
> rjn
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

Performing Asynchronous operation

Hi

I have 2 operations to perform one is to upload data and the second is
to generate report. Both take huge time(more than 20 mins and I believe
by that time session would have expired) and hence has to be done
asynchronously.

For uploading data, user will click start button and the asynchronous
operation has to start immediately.

For report generation, user will enter a time when the report has to be
generated(weekend date time) and press start button. The asynchronous
operation should start only at this designated time.

How can I do the above 2 operations?

Thanks

rjn

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!You need to read up on threading or use an asynchronous web service for your
first problem. Check out http://www.15seconds.com/issue/031124.htm.

For the second item, you don't say what your system is. If SQL Server, pop
the date and time into a field that can be scanned by a SQL Agent Job every
ten minutes or so. When the record is within ten minutes of the current
time, fire off a stored procedure.

If not SQL, you could achieve something similar using a file and Windows
Scheduler.

"RJN" <rjn@.yahoo.com> wrote in message
news:%23TA15ehrEHA.2000@.tk2msftngp13.phx.gbl...
> Hi
> I have 2 operations to perform one is to upload data and the second is
> to generate report. Both take huge time(more than 20 mins and I believe
> by that time session would have expired) and hence has to be done
> asynchronously.
> For uploading data, user will click start button and the asynchronous
> operation has to start immediately.
> For report generation, user will enter a time when the report has to be
> generated(weekend date time) and press start button. The asynchronous
> operation should start only at this designated time.
> How can I do the above 2 operations?
> Thanks
> rjn
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Wednesday, March 21, 2012

Permissions needed for user to upload file to an App_Data subfolder

I saw a recent note here that user file uploads should be directed to a
subfolder of App_Data to avoid site recompilation each time a file is
uploaded. That worked fine on my development machine, but when I deployed to
a test site at my web host, it fails:
Access to the path '...\App_Data\PDFFiles\Filename.pdf' is denied.
How do I set permissions to allow writing a file into that folder? Is this
something I do in my page or site configuration, or do I need to contact the
web hosting company?This is usually done through the web host or their control panel. IIS is
giving the error because the directory permissions set don't enable the
ASP.Net (or sometimes another account such as Network Services depending
upon the windows server version) user account to write to the directory. So
yes, you'll need to start with the host. There may be an automated way to do
this in the control panel so check there first.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"Paul Shapiro" <paul@.hideme.broadwayData.com> wrote in message
news:%23PwJ2hmgIHA.4396@.TK2MSFTNGP04.phx.gbl...
>I saw a recent note here that user file uploads should be directed to a
>subfolder of App_Data to avoid site recompilation each time a file is
>uploaded. That worked fine on my development machine, but when I deployed
>to a test site at my web host, it fails:
> Access to the path '...\App_Data\PDFFiles\Filename.pdf' is denied.
> How do I set permissions to allow writing a file into that folder? Is this
> something I do in my page or site configuration, or do I need to contact
> the web hosting company?
Thank you Mark. Folder permissions were not accessible in the web host's
control panel. I sent an email request and they added the permissions for
the web account. It's working now.
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:eopxMJ8gIHA.2448@.TK2MSFTNGP03.phx.gbl...
> This is usually done through the web host or their control panel. IIS is
> giving the error because the directory permissions set don't enable the
> ASP.Net (or sometimes another account such as Network Services depending
> upon the windows server version) user account to write to the directory.
> So yes, you'll need to start with the host. There may be an automated way
> to do this in the control panel so check there first.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - Expression
> "Paul Shapiro" <paul@.hideme.broadwayData.com> wrote in message
> news:%23PwJ2hmgIHA.4396@.TK2MSFTNGP04.phx.gbl...

Permissions Problem

Hi

I have created a facility to allow the user to upload an
image file to the webserver. When the user creates the
image for the first time i.e. the image does not exist
within the directory everything works fine. The problem
occurs if my ASP.NET dll tries to delete the file or
overwrite it?

I assume my app will be using the ASPNET account and I
have ensured that this account has full control over the
directories in question etc.

Anyone any thoughts?

Thanks in advance

AndyWhat is the error?

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Andy" <andy@.thecodeclinic.net> wrote in message
news:0e7c01c3b42b$a2d2c020$a501280a@.phx.gbl...
> Hi
> I have created a facility to allow the user to upload an
> image file to the webserver. When the user creates the
> image for the first time i.e. the image does not exist
> within the directory everything works fine. The problem
> occurs if my ASP.NET dll tries to delete the file or
> overwrite it?
> I assume my app will be using the ASPNET account and I
> have ensured that this account has full control over the
> directories in question etc.
> Anyone any thoughts?
> Thanks in advance
> Andy
Whoops!

I have since restarted IIS as well but to no avail??

this is the error generated:-

Source:
CodeClinic.RestWebPort.BusLogic.Image.Save

Exception:
Access to the
path "E:\Inetpub\Poachers\library\dishes\dish_8.jpg" is
denied.

Trace:
at System.IO.__Error.WinIOError(Int32 errorCode,
String str)
at System.IO.FileStream..ctor(String path, FileMode
mode, FileAccess access, FileShare share, Int32
bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode
mode)
at System.Web.HttpPostedFile.SaveAs(String filename)
at CodeClinic.RestWebPort.BusLogic.Image.Save(String
file, HtmlInputFile uploadedfile)

>--Original Message--
>What is the error?
>--
>Kevin Spencer
>..Net Developer
>Microsoft MVP
>Big things are made up
>of lots of little things.
>"Andy" <andy@.thecodeclinic.net> wrote in message
>news:0e7c01c3b42b$a2d2c020$a501280a@.phx.gbl...
>> Hi
>>
>> I have created a facility to allow the user to upload
an
>> image file to the webserver. When the user creates the
>> image for the first time i.e. the image does not exist
>> within the directory everything works fine. The problem
>> occurs if my ASP.NET dll tries to delete the file or
>> overwrite it?
>>
>> I assume my app will be using the ASPNET account and I
>> have ensured that this account has full control over
the
>> directories in question etc.
>>
>> Anyone any thoughts?
>>
>> Thanks in advance
>>
>> Andy
>
>.
SORTED!

It seems that under Windows 2003 the process is NOT
running under the ASPNET account but a NETWORK SERVICES
account?

However if this is the case how is it writing the first
file upload successfully to the directory?

weird!

It is now working though, which is nice ;-)

>--Original Message--
>What is the error?
>--
>Kevin Spencer
>..Net Developer
>Microsoft MVP
>Big things are made up
>of lots of little things.
>"Andy" <andy@.thecodeclinic.net> wrote in message
>news:0e7c01c3b42b$a2d2c020$a501280a@.phx.gbl...
>> Hi
>>
>> I have created a facility to allow the user to upload
an
>> image file to the webserver. When the user creates the
>> image for the first time i.e. the image does not exist
>> within the directory everything works fine. The problem
>> occurs if my ASP.NET dll tries to delete the file or
>> overwrite it?
>>
>> I assume my app will be using the ASPNET account and I
>> have ensured that this account has full control over
the
>> directories in question etc.
>>
>> Anyone any thoughts?
>>
>> Thanks in advance
>>
>> Andy
>
>.
There are only 2 possible reasons why your app might be denied access to the
file:

1. It doesn't have the necessary permission
2. The file is in use by an application and locked.

You can easily determine whetyher it's number 2 or not. If you can delete
the file and the app cannot, the problem is number 1. When a file is locked,
even the Administrator group can't delete it.

If the problem is number 1, re-check your permissions. And remember that
Deny permission always overrides Grant. In other words, if you have granted
the user permission, and somewhere else that permission is explicitly
denied, the permission is not granted.

You may also want to make sure that the account you think ASP.Net is running
under is indeed the account it is running under. To do this, just open up
Task Manger, check the Processes tab. The user account under which your
ASP.Net worker process is running will be displayed.

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Andy" <andy@.thecodeclinic.net> wrote in message
news:115701c3b431$a6b765a0$a301280a@.phx.gbl...
> Whoops!
> I have since restarted IIS as well but to no avail??
> this is the error generated:-
> Source:
> CodeClinic.RestWebPort.BusLogic.Image.Save
> Exception:
> Access to the
> path "E:\Inetpub\Poachers\library\dishes\dish_8.jpg" is
> denied.
> Trace:
> at System.IO.__Error.WinIOError(Int32 errorCode,
> String str)
> at System.IO.FileStream..ctor(String path, FileMode
> mode, FileAccess access, FileShare share, Int32
> bufferSize, Boolean useAsync, String msgPath, Boolean
> bFromProxy)
> at System.IO.FileStream..ctor(String path, FileMode
> mode)
> at System.Web.HttpPostedFile.SaveAs(String filename)
> at CodeClinic.RestWebPort.BusLogic.Image.Save(String
> file, HtmlInputFile uploadedfile)
>
> >--Original Message--
> >What is the error?
> >--
> >Kevin Spencer
> >..Net Developer
> >Microsoft MVP
> >Big things are made up
> >of lots of little things.
> >"Andy" <andy@.thecodeclinic.net> wrote in message
> >news:0e7c01c3b42b$a2d2c020$a501280a@.phx.gbl...
> >> Hi
> >>
> >> I have created a facility to allow the user to upload
> an
> >> image file to the webserver. When the user creates the
> >> image for the first time i.e. the image does not exist
> >> within the directory everything works fine. The problem
> >> occurs if my ASP.NET dll tries to delete the file or
> >> overwrite it?
> >>
> >> I assume my app will be using the ASPNET account and I
> >> have ensured that this account has full control over
> the
> >> directories in question etc.
> >>
> >> Anyone any thoughts?
> >>
> >> Thanks in advance
> >>
> >> Andy
> >.
Hi Andy,

Thank you for posting to the MSDN newsgroups.

I am glad to know that the problem is resolved. You are right that the
default account is the Network_Service account in Windows 2003 Server (IIS
6). If you want to change the account, please refer to the following
article.

INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/defaul...kb;en-us;306158

If you have any more concerns, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Thanks guys :-)

>--Original Message--
>Hi Andy,
>Thank you for posting to the MSDN newsgroups.
>I am glad to know that the problem is resolved. You are
right that the
>default account is the Network_Service account in
Windows 2003 Server (IIS
>6). If you want to change the account, please refer to
the following
>article.
>INFO: Implementing Impersonation in an ASP.NET
Application
>http://support.microsoft.com/default.aspx?scid=kb;en-
us;306158
>If you have any more concerns, please feel free to let
me know.
>Best regards,
>Jacob Yang
>Microsoft Online Partner Support
>Get Secure! C www.microsoft.com/security
>This posting is provided "as is" with no warranties and
confers no rights.
>.