locked
How to create virtual folder in IIS for ASP.NET 2005 web project RRS feed

  • Question

  • User-282341452 posted
    I have installed VS 2005 and created a web application as file system and i'm using SQL 2003 database in another machine and when i run my project its going fine. (Connecting to db)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>Now i created a virtual folder in IIS and mapped my web project folder to it. ( "http://localhost/Test/" )<o:p></o:p>Now when i access my application thru the address its throwing Server Error  (i have VS 2003 also in my machine)<o:p></o:p>i don't want to connect to SQL 2005. Any settings have to be done in IIS ??<o:p></o:p>Thankz in advance.<o:p></o:p>

    An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) <o:p></o:p>

    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: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error: <o:p></o:p>

    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. <o:p></o:p>

    <o:p> </o:p><o:p> </o:p>

     

    Friday, August 10, 2007 3:38 AM

Answers

  • User-2017008401 posted

    Hi pkarthik,

    From your description, I understand that after creating virtual directory for the existing web project, the web site failed to connect to the SQL Server 2005. However, debug the project in Visual Studio works well. If I have misunderstood your concern, please let me know.

    Based on my experience, the most likely cause of this issue is the login account. When view the page through IIS, the build-in account: “ASPNET” account (for IIS 5) or “Network Service” account (for IIS 6) will fail to connect the SQL Server.

    To fix this issue, you can choose one of the solutions:

        1. Change the Authentication Mode to SQL mode in connection string, for example:

    <STRIKE>Data Source=ServerAddress;Initial Catalog=database;Integrated Security=True</STRIKE>
    Data Source= ServerAddress;Initial Catalog=database;User ID=***;Password=*****

        2. Use ASP.NET impersonation.

    ASP.NET Impersonation 
    http://msdn.microsoft.com/en-us/library/xh507fc5(vs.80).aspx

        3. Add build-in ASP.NET account in SQL Server logins.

    In SQL Sever Management Studio, expand “Security” node, right click “Logins” node and select “New Login…”. Add “machineName\ASPNET” or “machineName\Network Service”

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2007 4:12 AM

All replies

  • User-1091210821 posted

    You topic and your error look different. Please specify whats the issue.

    Your error is to do with your application unable to connect to SQL server

    Friday, August 10, 2007 4:50 AM
  • User-2017008401 posted

    Hi pkarthik,

    From your description, I understand that after creating virtual directory for the existing web project, the web site failed to connect to the SQL Server 2005. However, debug the project in Visual Studio works well. If I have misunderstood your concern, please let me know.

    Based on my experience, the most likely cause of this issue is the login account. When view the page through IIS, the build-in account: “ASPNET” account (for IIS 5) or “Network Service” account (for IIS 6) will fail to connect the SQL Server.

    To fix this issue, you can choose one of the solutions:

        1. Change the Authentication Mode to SQL mode in connection string, for example:

    <STRIKE>Data Source=ServerAddress;Initial Catalog=database;Integrated Security=True</STRIKE>
    Data Source= ServerAddress;Initial Catalog=database;User ID=***;Password=*****

        2. Use ASP.NET impersonation.

    ASP.NET Impersonation 
    http://msdn.microsoft.com/en-us/library/xh507fc5(vs.80).aspx

        3. Add build-in ASP.NET account in SQL Server logins.

    In SQL Sever Management Studio, expand “Security” node, right click “Logins” node and select “New Login…”. Add “machineName\ASPNET” or “machineName\Network Service”

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2007 4:12 AM
  • User-282341452 posted

    Hi Benson Yu,

    Thankz a lot ur reply helped me and i chosed second option (impersonation) and it worked perfectly.

    (FYI i'm not using local 2005 SQL Server, I'm connecting to 2003 SQL Server located in another machine)

    Once again Thankz

    Regards,

    Karthik

     

    Monday, August 13, 2007 4:38 AM