I had a website that is running perfectly fine,
However when I decided to move it to Azure (Uploaded by FTP), I get the error
System.ComponentModel.Win32Exception: Access is denied
The connection to my database hosted in my own server's SQLServer could not be opened.
Is there any additional steps to be made after uploading the entire website?
Assuming you imported your Model locally, you need to update your connectionString from your Web.config file. Set your server, catalog, user id, and password appropriately
Related
I am trying to host a WordPress website on azure.
I have successfully uploaded the files and database in phpMyAdmin.
I checked which user is accessing my database its shows as azure.
When I try to open the link (https://websitename.azurewebsites.net/) where its is hosted on azure ,it gives the following error:
An attempt was made to access a socket in a way forbidden by its
access permissions. Error establishing a database connection
Can someone tell me where can I find the right user name and password to connect to phpMyAdmin in azure
I tried using the FTP details, I connected in FTP but giving an error when try opening the website using link mentioned above.
If you just click the App Services menu and you add a new one, you can filter for WordPress and there are a lot of preinstalled instances, you can just start to use it. It is already configured for your.
My ASP.NET project has an MDF database in App_Data folder.
The connection string is:
Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;Integrated
Security=True;User Instance=True
It worked fine until I changed the project parameters to use "Local IIS Web server" instead of "Visual Studio Development Server".
The project now produces the following SqlException:
An attempt to attach an auto-named database for file
C:\Users\Admin\documents\visual studio
2010\Projects\SL\SL\App_Data\MainDatabase.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share.
How to modify the connection string to make it work with IIS?
You'll probably find this is file permissions (the error does state: "or specified file cannot be opened"). IIS runs as a limited-user by default, and it's unlikely to have access to the Administrators home directory.
Your three options are:
Change the identity of the application pool in IIS to run as a user that
does have access to that folder
Move the MDF file to a location that
IIS can access (and then check the permissions of the file)
Change the permissions of the file (and possibly the directories above it) so that IIS can access the file.
Of these, number 2 is the most desirable. The other two reduce security somewhat - the first, by giving IIS free reign over a lot of the file system (and potentially system resources as well); whilst the third has the potential to open up a user's home directory to IIS.
Since you are using Integrated Security, the user connecting has to map to a SQL Server login. When you changed to IIS, you switched the user and it may not map to a login in the DB. You could test this by specifying a username and password that are valid in your database.
For example:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;User Id=admin;Password=password;User Instance=True
Make sure the user account your IIS process is running as has correct permissions to that file.
I'm taking the database that I created with SQL server express and putting it on a server in a datacenter. There are 2 database files in AppData folder: the aspnetdb.mdf file and the file I created for my site MySite.mdf. I'm using the ASP login control and that works with the ASPNETDB.mdf file and it's working. If I log in without the correct username/pwd, it'll display a bad login message.
However, as soon as I login and the site goes to make a request to MySite.mdf, I get an error "Invalid object name 'dbo.Users'." which is the name of the first table the site looks into after the login.
I've attached the MySite.mdf file to the server and copied the connection string the hosting company is generating into the web.config file and left the rest as is.
Could it be that I can't attach a sql express file?
Please let me know if you've run into this issue or if you have any suggestions.
Thanks.
Based on your description and the following assumptions:
your authentication still works
you haven't mentioned attaching your aspnet.mdf
you have separate databases for security and datastore
you're probably still testing locally
I'd guess that your application is still pointing at your local aspnet database - that's why authentication still works. Typically in a shared host, you'll have to install/insert the asp.net security database items to your main database. See This MSDN page for instructions on setting up the asp.net database objects.
You need to establish whether or not you've actually attached your database or not. Is there an online "database manager" you can access? Or can you connect to your database from SSMS or your dev environment and run a simple query?
I have copied a DB from one my computers and using it here. On trying to open the page which requires the fetching content from DB, on con.open I am getting this exception:
Unable to open the physical file "E:\Program Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\cakephp.mdf". Operating system error 32: "32(The
process cannot access the file because
it is being used by another
process.)".
Unable to open the physical file "E:\Program Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\cakephp_log.LDF".
Operating system error 32: "32(The
process cannot access the file because
it is being used by another
process.)".
Cannot open database "cakephp" requested by the login. The login
failed.
Login failed for user 'Sarin-PC\Sarin'.
I have attached the database from Management Studio Express 2008 and I have also checcked the connection string. Here it is:
<connectionStrings>
<add name="cn" connectionString="server=.\sqlexpress;database=cakephp;integrated security=true;uid=sarin;pwd=******"/>
</connectionStrings>
In Visual Studio, when I test the connection, it says "Test connection succeeded". However, there is one strange thing going on. When I login to the Management Studio, there is no + sign with the newly attached database, as shown.
If the full WebConfig is reqiured to be seen, I have pasted it here: http://pastebin.com/sVAuN0Ug
There are users of the database, but, there are also users of the server. One user has to have login rights to SqlServer before it can use the database.
In your case you copied the database and it's users, but those users don't have login permissions on the new server. Solution would be to add a new Login account on SqlServer (go to the Security node of the SqlServer, not the Security node of the database), and add it there. When you add that user, assign it to the database as well, and that should work.
Edit: After reading your issue further, is it possible that there are two sql servers targeting the same mdf file? Because that cannot work. Also, when copying database files, have you detached them before copying? If that's all fine, then try making backup and then restore.
I am trying to use a textreader to retrieve data from a text file on a local machine. I have an upload routine to get the file for the reader to open.
When I run the application locally, it works fine. When I publish my application to my server, I am getting a Could not find a part of the path error. I assume this error has to do with permission in that the server cannot read from the local file system, but I don't know the proper way to remedy this.
do I set up the application to impersonate the user? I know I can't possibly set up each local users machine to allow the iusr account to access it.
Thanks for any thoughts.
UPDATE ****
I ensured that network service is they user for the app pool. I also ensured that the networkService has access to the local folder that the application resides in. I am running IIS7, and when I test the site, I am getting the error -
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that <domain>\<computer_name>$ has Read access to the physical path. Then test these settings again
I have tried suggestions from various posts, including adding domain\servername$ to the folder to allow access, but nothing seems to work.
Any thoughts?
Assuming this is IIS 6.5 or higher, the application pool user must have the necessary permission. By default, this is Network Service, which likely does not.
I solved this issue by first saving the file to the server, and then accessing the server's local file -
savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(file.FileName));
file.SaveAs(savedFileName);
The following blog helped me out - http://www.hanselman.com/blog/default.aspx?date=2008-06-28