Azure Web App Wordpress how to add Virtual Directory? - wordpress

Wordpress app is running fine at "/". I used the Kudu console to add a new filesystem folder, placed a hello.txt file in it, and then used the Path Mapping setting in the Azure portal to create a virtual directory to match.
I then navigated to the virtual dir in another web browser session, but Wordpress appears to be controlling the pathing because it gave the "not found" page.
How can I control the routes when I add another virtual dir to the app?
Thanks.

The below is my test to set the virtual directory.
Create the 'test' folder under 'site' folder in the KUDU, and put the 'test.txt' file in the folder.
Set the '/test' virtual path with site\test path.
Save the settings and restart the web, view the text file with the url https://your web name.azurewebsites.net/test/test.txt.

Related

Accessing Files on Network from IIS

I have a shared path \\mynetworkshare\myfolder which has images stored.
I have a domain user mydomainuser which was granted with read access to files in that path
I hosted website on IIS. I created a Virtual Directory within my IIS Site with an Alias myphotos pointing to the Physical path \\mynetworkshare\myfolder. I have also clicked on Connect as... button in the Add Virtual Directory dialog box and provided my mydomainuser credentials.
I clicked on the newly created virtual director myphotos and click on Content View in the right pane. I'm able to view all my photos within IIS. From this, I assume the setup of virtual directory to my shared drive is correct.
Now, the question is how do I access this Virtual Directory or Files in it from my code?
I have tried below
var filePath = Server.MapPath("~/myphotos/" + "myimage.jpg");
When I write the filePath to a log file, I see it is trying to map to a physical folder setup within my website folders.
Instead of pointing to
\\mynetworkshare\myfolder\myimage.jpg
it is pointing to
d:\wwwroot\inetpub\mywebsitefolder\myphotos\myimage.jpg
I know Server.MapPath resolves to a physical path of hosted site but I wonder if it behaves the same with my virtual directory.
Or Do I need to let ASP.Net know somehow that myphotos is a virtual directory created on IIS? Or Am I on the wrong path to get files? Do I need to write code something different?
You can get the physical path from IIS (7+) using System.Web.Administration (available in NuGet)
var physicalPath = new Microsoft.Web.Administration.ServerManager()
.Sites["Default Web Site"]
.Applications["/MyApplication"]
.VirtualDirectories["/MyVirtualPath"]
.PhysicalPath;
If the virtual directory is in the root, the Application is "/"
What's specified in the Connect as... may only apply to direct web requests. To access the files from your application, you will need to configure the Application Pool to use mydomainuser as its Identity (found under Advanced Settings...), or you will need to grant share permissions to the computer running IIS if the Application pool uses a built-in account.
The step that was missing is converting Virtual Folder as Application.
Right-click the Virtual Folder myphotos, click on Convert to Application
The link here should explain the steps
Without adding Server.MapPath, it works fine. For example
image.src = "~/myphotos/myimage.jpg"

New Files In IIS virtual directory return file not found

I have a virtual directory in IIS. and I added a new file to the physical directory that the virtual directory points to.
but when trying to access this file through the virtual directory - I get file not found (404).
I tried to restart the web site and the IIS Server - but it didn't help.
the file is a css file.
There may be permissions error on accessing the file so.
First set the permissions to full control over read /write..(Options->Security->...)
https://support.microsoft.com/en-us/kb/315122
You should generally put your static files under the Content folder in an MVC application. By default, this folder will be configured to skip the MVC routing rules. Google for MVC Content folder for more information.

Giving 404 error in web site ? Asp.net?

In web application, i created a site and place the code in my domain [using filezilla i upload the my pages in my domain ]. i place my folder which contain the code in domain like
BusinessEntity Folder, BusinessLayer Folder, DataAccess Layer and my code Folder. my web.config is my code folder. but when i type my url it is giving 404 error. Can you help me to solve this problem. Thank you.
404 - Not Found error. Some resource can't be obtained. Open Fiddler or any other web debugger and check what request return 404 error. After that check existing a resource corresponding to Url
Please check all these things are done properly
Publish the project from your local machine (using visual studio)
Upload the published project to the server.
Create a virtual directory in iis (in the server)
Map the virtual directory to the project folder (means select the physical directory as the project folder)
Do the necessary configuration changes (conection strings or appsettings)
Give write permission for the upload folder and error folder (If you use any)
Checkout http://www.advancedinstaller.com/user-guide/tutorial-iis.html

Remap/Create Virtual Directory for Project folder with IIS

I am getting following message while opening my project in Web Application.
The Web project 'MyProjectName' is currently configured to use the URL
'http://localhost/ProjectName'. The Web server has this URL mapped to
a different folder 'Physicalpath of the project'. Would you like to
remap this URL to point to this Web project's folder?
Any Idea how to disable/enable this message ?
you have two options:
a) either update the url of the project and create a new virtual directory for the project
or
b) update the path of the site that you have already configured by navigating to inetmgr and then updating the path to the new location

why it is still necessary to create virtual directory in IIS when website content is placed in IIS root directory

As virutal directory points to physical path of the application, so if the IIS root directory is C:\inetpub\wwwroot and the application is stored at D:\websites, than we need to create a virtual directory but if the application content is placed at C:\inetpub\wwwroot, then why still need to create virtual directory.
Actually you don't need to create a virtual directory. What you need to do is define it as an application folder, adding a virtual directory does this by default so that's why it works. All you really need to do is right click the folder under your website, click properties and under the Application Settings section click create. Your folder will then have a gear icon off to the side denoting it as an application folder.
As to why application folders are necessary, I believe it's a way of forcing you to choose which Application Pool you want the application running in rather than having every sub directory application running off the same pool by default.
IIS isn't used just for ASP.Net, it can serve up PHP for example...so the type of application and pool varies, it's not automatically created and tied to then ASP.Net engine.
If you can clarify a bit more what you're trying to do maybe we can help further. For example, if you want to point the root application to another folder and it be an application or create another website, IIS allows you to do any of that...you just need to update the question with which version of IIS, as the instructions very between them.
If the IIS site will host a single ASP.NET application you can place it at the root (C:\inetpub\wwwroot) and you don't need to create a virtual directory because when you create the site it is already a virtual directory.

Resources