Login problems after deploying to IIS

Posted on 2006-06-02
Last Modified: 2007-12-19
I am using VS2005 to build a simple web application. I am using the login control and a SQL Express database to validate the user. The login works fine when I run the web app from VS 2005, but when I deploy the application to IIS the logins fail, and when I try to retrieve the password I get the following error in the browser.

The MDF file is the same one that is in the VS 2005 project. WHat is different when I deploy?

Help please.


Server Error in '/WebSite1' Application.

Failed to update database "C:\INETPUB\WWWROOT\WEBSITE1\APP_DATA\ASPNETDB.MDF" because the database is read-only.
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.Data.SqlClient.SqlException: Failed to update database "C:\INETPUB\WWWROOT\WEBSITE1\APP_DATA\ASPNETDB.MDF" because the database is read-only.

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:

[SqlException (0x80131904): Failed to update database "C:\INETPUB\WWWROOT\WEBSITE1\APP_DATA\ASPNETDB.MDF" because the database is read-only.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857434
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735046
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
   System.Web.Security.SqlMembershipProvider.ResetPassword(String username, String passwordAnswer) +2226
   System.Web.Security.MembershipUser.ResetPassword(String passwordAnswer) +83
   System.Web.Security.MembershipUser.ResetPassword(String passwordAnswer, Boolean useAnswer, Boolean throwOnError) +34
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordQuestionView() +352
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword() +66
   System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
Question by:lachmann
    LVL 25

    Expert Comment

    Try opening IIS and then navigate to the database file.  Right-click the file and choose Properies.
    A dialogue box will open.  Under the File tab, check the box that says []Write.
    This will give IIS write-permissions.

    Author Comment

    I performed the above actions, and the same thing happens.
    LVL 25

    Expert Comment

    If you right-click the file in windows explorer and choose the Security tab (if memory server),  ensure that both IUSR and ASPNET accounts are both listed with write access to the file.
    LVL 25

    Accepted Solution

    There's some more information here
    LVL 2

    Expert Comment

    in your sharing and security of the individual file, add your default web user (normally inet_pub ) to the list of users. Then you can edit the permission of the webuser itself to read / write to the file. This allows for that one file itself to be written to by someone logged to the website hosted from IIS without actually compromising the security of sharing it publicly through the directory.

    I assume you are running IIS on a Windows XP or newer server.

    Author Comment

    I am running IIS on Windows XP.

    I am still not having any luck with this.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now