Server error on first try, but succeeds in subsequent tries (accessing files)?

J

Joergen Bech

Fairly new to ASP.NET 1.1. Getting the error below when running
application on a web server outside of my control, but only the first
time I run it:

1. After a long period of inactivity (or updating the code-behind dll)
accessing any aspx page in the application causes the application
to run for the first time. Some of the initialization involves
reading and writing some text and xml files using simple streamreader
and streamwriter objects.
I get a Windows Logon dialog(?) After clicking Cancel, I get the
error below.

2. After getting the initial error, all I have to do is press F5
(refresh) in IE and everything is fine. No errors or login dialogs
when accessing the same page or other pages.

Though the server is outside of my control (only ftp access), surely
I must be able to change a setting in my program that will make it
work without displaying the initial Windows Logon dialog, seeing
that everything works afterwards?

I have included the web.config file as well. Only changes I have made
are (as far as I remember):

<customErrors mode="Off" />
<authentication mode="Windows" />
<identity impersonate="true" />

Any ideas?

TIA,

Joergen Bech


-------------------------------------------------
--- error message ---------------------
-------------------------------------------------

Server Error in '/' Application.
--------------------------------------------------------------------------------

Access to the path "d:\web\mydomain.dk\www\webapplication.xml" is
denied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the
path "d:\web\mydomain.dk\www\webapplication.xml" is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if
the application is not impersonating. If the application is
impersonating via <identity impersonate="true"/>, the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user.

To grant ASP.NET write access to a file, right-click the file in
Explorer, choose "Properties" and select the Security tab. Click "Add"
to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:


[UnauthorizedAccessException: Access to the path
"d:\web\mydomain.dk\www\webapplication.xml" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize) +44
System.IO.StreamWriter.CreateFile(String path, Boolean append) +55
System.IO.StreamWriter..ctor(String path, Boolean append, Encoding
encoding, Int32 bufferSize) +49
System.IO.StreamWriter..ctor(String path) +60
mydomain.modFileFunctions.WriteTextFile(String strData, String
FullPath, String ErrInfo)
mydomain.CMSItem.Save(String FilePathName, Boolean UseCompression,
Boolean IncludeProperties, Boolean IncludeMembers, Boolean IsGraph)
mydomain.modVBTestData.SaveApplicationData()
mydomain.modVBTestData.CreateTestData()
mydomain.Global.Application_Start(Object sender, EventArgs e)


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.510;
ASP.NET Version:1.1.4322.510





-------------------------------------------------
--- web.config ---------------------
-------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>

<httpHandlers>
<add verb="GET"
path="FtbWebResource.axd"
type="FreeTextBoxControls.AssemblyResourceHandler,
FreeTextBox" />
</httpHandlers>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols
(.pdb information)
into the compiled page. Because this creates a larger file
that executes
more slowly, you should set this value to true only when
debugging and to
false at all other times. For more information, refer to the
documentation about
debugging ASP.NET files.
-->
<compilation defaultLanguage="vb" debug="true" />

<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom
error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.

"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to
users not running
on the local Web server. This setting is recommended for
security purposes, so
that you do not display application detail information to
remote clients.
-->
<customErrors mode="Off" />

<!-- AUTHENTICATION
This section sets the authentication policies of the
application. Possible modes are "Windows",
"Forms", "Passport" and "None"

"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or
Integrated Windows) according to
its settings for the application. Anonymous access must be
disabled in IIS.
"Forms" You provide a custom form (Web page) for users to
enter their credentials, and then
you authenticate them in your application. A user
credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized
authentication service provided
by Microsoft that offers a single logon and core profile
services for member sites.
-->
<authentication mode="Windows" />
<identity impersonate="true" />

<!-- AUTHORIZATION
This section sets the authorization policies of the
application. You can allow or deny access
to application resources by user or role. Wildcards: "*"
mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->

<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
<!-- <allow users="*" /> -->
</authorization>

<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every
page within an application.
Set trace enabled="true" to enable application trace
logging. If pageOutput="true", the
trace information will be displayed at the bottom of each
page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from
your web application
root.
-->
<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />


<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests
belong to a particular session.
If cookies are not available, a session can be tracked by
adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

<!-- GLOBALIZATION
This section sets the globalization settings of the
application.
-->
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

</system.web>

</configuration>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top