0

I'm trying to configure ASP session state on SQL Server but running into an issue. I'm following the steps listed here:

https://www.codeproject.com/articles/104082/configuring-asp-session-state-on-sql-server

I navigated to the proper directory C:\Windows\Microsoft.NET\Framework64\v4.0.30319 and run the following command:

aspnet_regsql.exe -S MyServerName -U MyUserName -P MyPassword -ssadd -sstype p

However, I keep getting the same error message:

An error has occurred. Details of the exception:
Login failed for user 'MyUserName'.
Unable to connect to SQL Server database.

I have access to the server and I'm able to access it through SQL Server Management Studio so what can be the cause of this issue?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
rin102102
  • 21
  • 2
  • 1
    Its a standard login error. There is something wrong in your connection string or the user does not have acess. – alexherm Jul 20 '20 at 17:27
  • Take a look at this answer: https://stackoverflow.com/questions/14733329/how-to-use-aspnet-regsql-exe – Pete -S- Jul 20 '20 at 17:27
  • @aleherm That must be the issue. It's odd that I'm able to access the server through sql management studio with those same credentials though – rin102102 Jul 20 '20 at 18:25
  • @Pete-S- I tried that as well but got this error message "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding." – rin102102 Jul 20 '20 at 18:26
  • @rin102102: When you connect via SSMS are you using the same credentials or NT Authentication? Did you setup the SQL Server, where the server running (locally or remotely)? Some issues I run into with connectivity: https://nettrax.net/2014/09/12/checklist-to-allow-remote-connection-to-sql-server/ – Pete -S- Jul 20 '20 at 19:11
  • @Pete-S- I'm using SQL Server Authentication with the same credentials and can connect with no problem. The server is remote. Do I need a special permission to run aspnet_regsql.exe, which is supposed to set up the database and all the necessary tables? Also, I believe the query timeout is set to 30 seconds, maybe that's not long enough? – rin102102 Jul 20 '20 at 19:18
  • If I have the wrong user id or password I get the same error as you do. Otherwise, I get an error; but, that is due to the user does not have rights: An error occurred during the execution of the SQL file 'InstallSqlState.sql'. Th e SQL error number is 262 and the SqlException message is: CREATE DATABASE permi ssion denied in database 'master'. SQL Server: SQL2016 Database: aspnetdb SQL file loaded: InstallSqlState.sql – Pete -S- Jul 20 '20 at 21:30
  • @Pete-S- It's weird because I know I'm putting in the right user id and password because it works in SSMS and also when running through the wizard. But when I run it through the wizard the error I get is: Exception: An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is -2 and the SqlException message is: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. – rin102102 Jul 20 '20 at 21:49
  • @Pete-S- Ok, I think I figured out what the issue is. My database is an Azure SQL database and apparently "Microsoft does not support SQL Session State Management using SQL Azure databases for ASP.net applications" so I don't know how I'm supposed to work around this – rin102102 Jul 20 '20 at 22:29
  • Can you run it against a local database and then script the databases out, run the script in SQL Azure? – Pete -S- Jul 21 '20 at 13:05

0 Answers0