SQL Server user instance could not be created due to a failure to retrieve the data path of the local user application

net project in vs2010 I have a db and a table inside the app_data folder, I created a deployment package and imported the package to the iis server that is installed on my local mechine. I now get this error message when I try to paste.

The SQL Server user instance could not be created due to a failure to find the data path of the local application user. Verify that the user has a local user profile on the computer. The connection will be closed

connection string:

Data Source =. \ SQLEXPRESS; AttachDbFilename = | DataDirectory | \ survey.mdf; Integrated Security = True; User Instance = True

when running inside VS2010 it works fine.

how can i solve this problem?

+4
source share
5 answers

Remove User Instance=True . You do not need RANU . Then verify that the SQL Server Express service account

+7
source

This article helped solve this problem: http://support.microsoft.com/kb/2002980

Edit From an MSDN article (if the link disappears):

Resolution for Windows 7 and Windows Server 2008 R2

For all web applications running under IIS 7.5, regardless of their project type, follow these steps:

  • Run the IIS Manager tool. This tool can be accessed either from the Administration menu or type inetmgr in the Start → Windows Search text box and select the inetmgr tool.
  • In the left pane of the IIS Manager tool, expand the node machine. Click the "Application Pools" node to display the application pools in the main window of the management tool.
  • If you are trying to troubleshoot an ASP.NET 2.0 / 3.0 / 3.5 application, select the "DefaultAppPool" application pool. For ASP.NET v4, select the ASP.NET v4.0 application pool.
  • Right-click the selected application pool and select Advanced Settings
  • In the Advanced Options dialog box, find the Process Model category. The first line in the category will be "Identity," the line.
  • Click on the "Identification" line, and then click on the small button that appears on the right side of the value cell. The button displays the text "..."
  • The Application Pool Identifier dialog box appears. There are two radio buttons inside this dialog box. Make sure the first radio button named "Built-in account" is selected.
  • In the drop-down list below the radio button, select "Network Service" for identification.
  • Click OK to close the Application Pool Identifier dialog box.
  • Click OK to close the Advanced Settings dialog box.
  • At this point, changes to the application pool identifier will be saved to the IIS 7.5 configuration repository.

Permission for web application projects and websites

For web application projects (WAPs) and websites located in the Documents folder located on any version of IIS running as NETWORK SERVICE, follow these steps:

  • First confirm that IIS is configured to run as NETWORK SERVICE. This is the default value for IIS6 and IIS7. However, if you are running Windows 7 or Windows Server 2008 R2, you first need to follow the steps in the "Permission for Windows 7 and Windows Server 2008 R2" section above to have IIS application pools run as NETWORK SERVICE.
  • At the command prompt, type net stop iisadmin / y. This will exit all running ASP.NET WAP applications.
  • Quit all running Visual Studio instances.
  • NETWORK SERVICE must be granted permission to read the Visual Studio top-level folder located in the User Documents folder. The Visual Studio folder will have different names depending on the version: "Visual Studio 2005", "Visual Studio 2008" or "Visual Studio 2010".
  • NETWORK SERVICE must be granted permission to read and write to the project folder of the top-level project. For example, if your WAP project is called "MyCustomWebProject", then the "Documents \ Visual Studio 20xx \ Projects \ MyCustomWebProject" folder must have read and write access for NETWORK SERVICE. Or, if your webiste project is called "MyCustomWebProject", then the "Documents \ Visual Studio 20xx \ Websites \ MyCustomWebProject" folder must have read and write access enabled for NETWORK SERVICE.
  • NETWORK SERVICE must be granted read and write permission to the App_Data folder located in the directory of your web project structure.
+7
source

SOLUTION FOR THE ENVIRONMENT:

Win 7, IIS 7.0, Visual Studio 2010, Database.mdf

Open the web configuration and check the conexion line:

Importantly, make sure that AttachDbFilename does not follow C: \ inetpub \ <> \ App_Data \

 <add name="conexion" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|Database.mdf; Integrated Security=True; User Instance=True" /> 

In IIS 7.0 Go to ApplicationPools, find the application pool created for the application.

  • Click Advanced Options
  • Go to Identity and open it. Choose Custom
  • Account and setting up a PC or server administrator account

Then go to the website in IIS 7.0 and click on it ...

  • Find and double-click the Identification icon
  • Click "Anonymous Authentication" and select "Edit", then "Application Pool Identifier"

    Find the impersonation and edit of ASP.NET, select "Specify User" and enter the credentials.

Restart IIS: cmd> iisreset / noforce or click image reset

+3
source

Decision with me

  - On IIS ->> Application pool - Select Default App Pool (it may be different of your website, please choose your pool) - Advanced setting - Identity: ApplicationPoolIdentity - Load user profile: change to true Restart IIS 
+3
source

RUN-> INETMGR->
go to Sites, select your site
Then go to the right panel and find "Basic Settings"
Then click “Connect As”, then select “Specific User”, then click “Install”
Enter the name and password of the local computer, then click "OK"

Then click “Test Setting” if you see both options in green, then “OK”.
Problem resolved
Enjoy ...

0
source

Source: https://habr.com/ru/post/1336628/


All Articles