I want to debug my asp.net application in same directory than I publish, so absolute paths are the same as real environment.
I try to activate use local IIS in "Web" properties but I get an error saying: I need to create virtual directory (actually it already exists in that directory) and if I try to creat it I get a cryptic error saying there is already a different folder assigned (or something similar)
Thank you
You mean to debug from the local IIS or any remote server directly right?
Close the VS. Open the .sln file in notepad, there will be a line on top like
Project("{random numbers}") = "test", "..\..\WebSites\test\", "{random numbers}"
Change the second parameter (relative path of your project folder in file system) to the address of your virtual directory. Like:
Project("{random numbers}") = "test", ""http://localhost/test/"", "{random numbers}"
Also if you are using IIS7, change the virtual directory to application.
Related
I recently bought a new computer. I moved the drives from my old computer to the new one, installed everything I needed to and opened my project. Now I'm trying to run my project in IIS express but it displaying an error specifying an html output as log file.
When I look at the html problem, it's a 500 error message generated by what looks likes an IIS page. It's saying that the config file cannot be found:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid
Config File
\\?\F:\Development\MyProject\API\web.config
When I switched to the new machine drive letters were changed, so the code I'm running is no longet on drive F like in the message above - it's now on a different drive. I've looked in my code - I have no reference anywhere to a specific path.
I've tried to do clean and rebuild but it doesn't work.
If I look inside files for the path I see that the DLLs are compiled with PDB file path inside them. Why is that? And what happens later on on production?
Also, how do I fix this problem? why does it keeps looking for old location?
I'm fairly sure the IIS Express metabase still has the old path configured for this site. Please see the following answer for how to locate the metabase file (it's usually here: \Documents\IISExpress\config\applicationhost.config):
Where is the IIS Express configuration / metabase file found?
I'm not sure what the most correct way is to correct the problem, but you should be able to manually edit this file and update the "physicalPath" attribute for your site to the correct path to resolve this problem.
I don't know the exact cause of my problem, but the solution was to delete all bin directories from all project folders and re-compile.
To delete the bin directory from all my project I wrote the following PowerShell script:
Get-ChildItem -Path . -Filter *bin* –Recurse | Remove-Item -Recurse -Confirm
I have MSDeploy successfully deploying a web package zip file to a remote IIS website using a command like this
MyDeployCommand.deploy.cmd /T /M:https://MyServer:8172/msdeploy.axd -allowUntrusted /U:Username /P:Password /A:Basic "-setParam:name='IIS Web Application Name',value='My Website Name'"
Although this works, it defaults to the current directory that the website is pointing to. I'd like to change the physical path. I've tried a number of parameters with no success and was wondering if this is even possible to do.
Thanks to chief7 for pointing out the appcmd, which on the target works eg
%windir%\system32\inetsrv\appcmd set site /site.name:"My Website Name" /application[path='/'].virtualDirectory[path='/'].physicalPath:"C:\new\path"
However if I try the same thing on the remote machine eg
"%MSDeployPath%msdeploy.exe" -verb:sync -source:runCommand="%windir%\system32\inetsrv\appcmd.exe set site /site.name:;quot;My Website Name;quot; /application[path='/'].virtualDirectory[path='/'].physicalPath:;quot;C:\new\path;quot;",dontUseCommandExe=true -dest:auto
Its coming back with
Error: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) which I assume is referring to the appcmd. I added
dontUseCommandExe=true
to get around the problem of it being called via cmd.exe
You can extend the WebDeploy manifest to alter the site/app path with a RunCommand provider.
<runcommand path="%windir%\system32\inetsrv\appcmd set app /app.name:"Default Web Site/app12" /[path='/'].physicalPath:C:\temp\app12" waitInterval="5000"/>
http://www.dotnetcatch.com/2016/06/28/webdeploymsdeploy-quick-tip-change-iis-siteapp-physical-path-with-msdeploy/
http://www.dotnetcatch.com/2016/05/19/extending-the-webdeploy-manifest/
The appHostConfig provider is also supposed to let you change the directory but this was easier.
I'm trying to read a file in a virtual path, using the following code
HostingEnvironment.VirtualPathProvider.FileExists(_SiteMapFileName)
_SiteMapFileName has something like "~/Content/en-US/MainMenu.sitemap" and it is always returning false.
But if I access the URL of that virtual path (http://www.local.mysite.com/Content/en-US/MainMenu.sitemap), the file displays correctly in the browser
Content is a virtual directory under my website, pointing to a shared folder on a different location. If I access that location on Windows Explorer I can see the files correctly
I've set the site and the virtual directory to connect as my network account.
I used the process monitor tool to see if there's any problem and it says that w3wp.exe is trying to create the file \path\to\shared\location\Content\en-US\MainMenu.sitemap but it is getting ACCESS DENIED which is fine since it is a read-only location
Does anybody now how to solve this issue?
I found out the reason. The user set to run the app pool tied to the application needs to have permissions on the file is trying to read, not only the website and the virtual directory. :/
when i am working with vDir i use Server.MapPath
Does that not work for you?
if(System.IO.File.Exists(Server.MapPath("Relative Path to vDir")))
{
//do something with the file
}
I have taken a Branch of a Project from TFS. Another branch is already in my computer.
The projects contains a virtual directory which is hosted in my system's IIS (5.1) and takes path from there
After getting all files to my computer , VS 2008 says that the Virtual Directory already exists in the IIS and do I want to overwrite it?
When I select No it creates another Virtual Directory with the same name but with suffix _1
I don't like this name and I want to rename the suffix with _Branch_1
I tried by going to inetmgr and renaming the Virtual Directory -> Application Name in properties of VD.
But it does not take effect , I also saw it after browsing a test aspx file from the site , URL still shows _1 suffix.
Every time I rename the Application Name and open Visual Studio , it shows same message and adds new suffix e.g. _2 next time _3 and goes on.
Any idea how to rename it?
Check the Solution file in your project. What the virtual direcotry has defined, open it in notepad and check.
To rename the Virutal direcotry, stop the app pool associated with the application and then you can rename it.
hope it may help you.
I have two web application hosted on different server.For eg. one is main application and the other one is branch application.
In branch application, user will upload their files but we want to keep all uploaded files in main application virtual directory.
So that we put the main application virtual directory path while we upload the files.But We got error message like "Invalid Directory" and can't upload.
Is there any way to upload files from one application to another directly? We are using normal html upload control in asp.net and visual studio 2008.
Code Sample :
main application virtual directory "http://10.10.10.1/mainapp/uploadedfiles/"
branch application virtual directory "http://10.10.10.2/branchapp/"
HttpPostedFile postedFile;
string saveFile = Path.Combine("http://10.10.10.1/mainapp/uploadedfiles/", "File1.pdf");
postedFile.SaveAs(saveFile);
Please guide me the right way and I really appreciated it.
Thanks.
Best Regards,
Chong
In the FileUpload control, the FileUpload.SaveAs(path) method takes a physical path, not a virtual path. So if you have a virtual path, you will need to use the Server.MapPath method to convert it to a physical path. Using your example, you might want to change the last line of your code to:
postedFile.SaveAs(Server.MapPath(saveFile))
Also, you will need to make sure that the account that ASP.Net is running under has ACL write permissions on the physical directory.
I think u can share the directory and ensure both the Apps can access it, because the two apps are in different servers, the directory path maybe just like : \serverA\Files\, and the url of this directory is : http://localhost/files. u can save files to other servers by a relative path if u have the permission.