I am developing asp.net mvc web application in VS2008.In my project,users will upload their files.So that,we created a one folder and made virtual directory in IIS for it.That is just simple folder to store the files.But that folder path is not same with our application path and it is a separate folder.
For eg : upload folder path is "http://localhost/uploadfolder" and our application path is "http://localhost/TestApplication
I use Server.MapPath("~/uploadfolder") to get that upload virtual directory path but it returns like "http://localhost/TestApplication/uploadfolder" and I got error message "Upload directory not found". I also tried like Server.MapPath("http://localhost/uploadfolder") but still can't to upload.
My question is how can I point to that path from my application? How can I upload the files? I haven't hosted yet my application in IIS and I run it from Visual Studio.Please guide me the right way.I really appreciate your answer.
Related
I have asp.net mvc application hosted on Azure as an App Service....Example.com
I need to have a location where my Google Shopping Feed can be hosted as a text file, so I created a Virtual Directory in my Azure portal for that Example.com App Service.
The virtual directory is Example.com/myvirtualdirectory
I created this by going to (Configurations > Path Mappings > + New Virtual application or directory) I named the virtual path as /myvirtualdirectory and then I named the physical path as site\wwwroot and the Type as a Directory.
Now that I have created the directory, how do I get my txt file containing my ShoppingFeed on that directory? When I access the url Example.com/myvirtualdirectory I see that a page from Azure is up and running that says: "Hey, App Service developers! Your app service is up and running.Time to take the next step and deploy your code."
The purpose of this is so that when Google is scheduled to get my latest feed data, it comes to that url and is able to see all my product feed info.
So how do I get my file onto that location? Do I have to upload it the first time somewhere inside the Azure Portal ?
Do I have to create the directory as well on my actual application within visual studio? If so how do I do that? How do I create a virtual path or directory inside of my actual project if that is what I have to do?
How will this affect my deployments going forward now that there is a VD in the mix? Currently the existing application does not have virtual directories and I am deploying by clicking on "Publish" within visual studio..It deploys straight to the Azure App Service.
I have project to upload image and view image on asp.net. everything work as i expected. i can upload image and saved to my folder then saved the folder to database, then from database i can show or view the image.
Unfortunately, after publishing to IIS and run the web UNDER IIS , image that i uploaded won't saved to folder and also the image that contains on my folder can't be viewed when running web under IIIS.
I tried to search in stackoverflow how to solve it and everyone said it's about permission i have tried option to set the security permission but nothing works
Folder settings:
Subfolder settings:
I suspect it could be perhaps a wrong path as your app is installed under the default web site... I often suggest to alwyAs start from the exact thing that happens to avoid guessing about issues.
Edit: the folder structure is really strange. It seems I have the default web site, created an application root under this web site but your main ScraBoy app volder is still under this folder ??? I believe I installed app one level below what you intended
Is it possible to create file in App_Data dir of MVC app while its running on Azure- App Service (Not Virtual Machine)?
Actually I have to download images from URL and save to the App_Data folder for further processing. I am able to do this in development laptop. I get the path of my App_Data folder using the below line and save files there:-
String localFileName = Server.MapPath("..\\App_Data") + "\\" + saveFileName;
I am not sure it is possible in the Azure's App Service.
What can be alternative way of doing it?
Please help.
I have two web application in my solution. One of them is for managing the system and another is for clients.
I should publish them one by one in separated places (of course on a machine but in separated addresses for Example http://manager.com and http://clients.com)
My question here is that, can clients web application access the files that the other manager web application has (in its physical directory)? If not how can I approach this problem?
see this design to get more details for this problem :
Thanks!
What I usually do in a scenario like this, is store the files in a folder in the application that does the writing. Then I use IIS to create a virtual directory in the other application that points to the folder containing the files in the first application.
So in your case, you could have a folder "Files" in the manager.com website. Let's say the folder has this full path: D:\Websites\manager.com\Files You can then create a virtual directory in the clients.com website pointing to that path.
This has the advantage that you can code everything as if the folder exists in both applications.
If your applications placed on one machine - certainly can.
You should do only one thing - give permission to folder with files (Or permission to DB with files) to user that run your web application on web server (Usually IIS if you use MVC < 5)
It seems from your comment that you want to share uploaded files between multiple web project. You can store them in a common folder outside your web project folder.
For example, create a folder in
"C:\Temp\" say "SharedFiles".
The manager web application that receives the file from user (through upload) can store the files in this folder. The client web application can refer this location for file while reading.
You may have to give permission to the user (IIS_IUSRS) to access this folder.
I have developed a web application using ASP.Net MVC 4, then hosted that web application on windows azure (windowsazure.com).
My website is unable to upload image/create file. Should I add some permissions?or how to add these permissions?
Please use Edit question to provide code snippet.
Give the code you've provided, the failing part is most probably the line:
Server.MapPath("~/UploadImages/" + ...);
What you really have to do, is first check whether that folder already exists:
string targetFolder = Server.MapPath("~/UploadImages");
if(!System.IO.Directory.Exists(taretfolder))
{
System.IO.Directory.Create(targetFolder);
}
// then copy the file here
The "problem", if one can say it is a problem at all, is that the server does not have this directory created when you try to put file into it. You have to first the directory before trying to copy files.
And by the way, it is not an "Azure" issue. If you take your code as is and upload it to a hoster (without manually creating or coping the UploadImages folder) you will encounter the very same issues.