Access Denied to files after coping to Server 2012 - asp.net

I have an ASP.NET application where my client has moved from Microsoft Server 2008 R2 to Microsoft Server 2012. My application saves and removes files from a local folder that we give permissions on. This works fine, I can add and remove uploaded files with ease.
The problem is, that any of the files that were uploaded from the old Server and copied over to the new server, they get an Access Denied when IIS tries to remove it. Now, like I said I can upload and remove new files without any problems. It is the old files that were uploaded to the old server and transferred over to the new server that will give the error.
Can anyone point me in the right direction as to how we can setup the permissions on these files so they can be accessed correctly on the new server?
Thanks,
Cory

Most likely the files where copied with old permissions. Try following on the new server:
In Windows Explorer Right-mouse click on the folder that holds the files and go to Properties, Security Tab
There click Advanced and Change Permissions
There check the "Replace All child Object Permissions" checkbox and click Apply
This should give all the old files the same permissions as new files.

Related

folder explorer for server files

Is it possible to rename/move or delete files from a web application (ASP.Net MVC) that are on a server folder just like how you would do it locally? I would want the user to be able to upload say 30 files (from a scanner auto-feed) into a temporary folder on the server (cannot save it locally due to data security) and then allow the user to be able to rename /move before uploading them onto Azure blob storage.
I saw few examples - jquery file tree seemed good but not sure if it allows rename and moving. Please suggest solutions for working with the server folder. I intend to delete the server folder after I am done transferring files to Azure. TIA.
Yes, you can do this by giving the USER that is running the ASP.Net application (defaults to IUSR) permissions to write to that folder.
Be very careful though, as you're potentially opening your website for abuse when doing this.
See: https://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis for how IIS users operate.

Can not access SQL Server database information

I am new to SQL Server databases. I used a SQL Server database in my website (I add it to my project by add new Item and now it is located in a App_Data folder). I can show the needed information of it in a gridview on my localhost but when I upload it on the web hosting server, I can not access it.
What is wrong with it? You can see it here: http://www.kaj.somee.com/SL.aspx
I'm using asp.net 2010 and vb.net
There is the error. See your excerpt (per comment). Do you really have your app_data folder in path
AttachDbFilename=C:\Users\Javad\Desktop\Sharj\App_Data\ShDB.‌​mdf
Does this path really exist in your hosting machine. I believe NO and in that case Change that path accordingly.

How do I get my web site to recognize a COM reference that may not exist on the server

I am creating an Excel spreadsheet from my web site. I have added a reference to the site through the properties page that points to the file C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe on my local drive. Everything works fine running locally. However, when I publish to the server where the site runs, I get an error because it can't see the Excel.exe file. Where does this file need to be in order for the site to see it?
Thanks
Most likely it's because your application is running as another login on the server as opposed to locally on your box. Investigate what user the application's app pool runs as, then ensure that user has read/execute access to the location on the server where the Excel.exe file is.

Access to the path 'C:\Sites\content\ServerIpAddress.txt' is denied

I create a web site that in Default web page of it i try to access to ServerIpAddress.txt file that is on server . now when i run my project on local host it work correctly , but when I upload it on Server(free host) i face with
error. can some one help me ?
You most likely do not have permissions access files on the shared server due to security issues. Consider moving data from that file to web.config app key.
or access the file as a relative path to your site. The remote sever will most likely not have the same folder structure as your local machine.
The account that is being used for the worker process of the web site has no (write)access to the file.
Configure the file (or folder) so that the ASP.NET process has access.
Another thing to look at is whether or not the path as stated in the code is the actual path on the server.
give full permission to ServerIpAddress.txt file. it will work.
Right click on content folder. Click Properties. Then from General tab uncheck the Read-only checkbox.
Then go to Security tab and Allow Write permission for your ASP.NET process.
Are you using a database? In that case how did you set up permissions for app_data folder? You have to set permissions in the same way.
If you are not able to do that, try moving the file inside of app_data folder and then check.
Right click on .txt file and select security and add network service .restart iis and try.It will work.

How can I save a Word document back to the main server from an ASP.NET intranet?

I have a ASP.NET intranet application that has a document library section. The user can click on a link to a MS-Word document that resides on the server and can then edit the document if required within the browser (IE).
The problem is that when they come to save their changes it needs to write it back to the server but instead wants to save it on their local system.
Any ideas how I can get it to save back to the main server ?
Thanks in advance.
you need to upload the file back to the server.
Is this a internet or intranet application? if intranet you could save directly to \\myServer\myFolder\...
If it's a internet application, so the end user does not access to the server files directly you need to create a Office Add In (using Visual Studio Tools for Office), called "Save to Server" and that will run "http://www.mydomain.com/updatefile.aspx" and that page will do a Update.
remember, Update with a filename diferent from the original, and if the update was ok, then delete the old, and rename the new (or give the user a version system and rename the file on the server to [myFile]_[currentDate].docx for example.
links:
How to upload a file to a Web server in ASP.NET by using Visual C# .NET
The link to the word document can be a file:// url.
Using this method the user can open the file directly on the share.
Assuming your intranet applicaiton supports writing back to the server, you would need to give the account that the web application runs as permission to write to the folder the documents are stored in, unless it is using impersonation then the users it is impersonating would need ther permissions.

Resources