Virtual directory problem in IIS for asp.net web application - iis

My asp.net web application works fine locally and when I deploy it as the default web site on my test server. So for example, when I type http:// 10.10.10.100 it works fine.
I created a virtual directory called "Test" under my "Default Web Site".
When I type http://10.10.10.100/Test it loads correctly to my log-in page, however when I log-in and click on a link it goes back to my log-in page and the url goes back referencing http://10.10.10.100 instead of http://10.10.10.100/Test/Default.aspx, for example.
My goal here is to run my application from the virtual directory and not as the default, but I don't want to change my code to a hard coded path since then it won't work anywhere else.
Any workarounds for this?

You have left a few unanswered questions, but some things to check:
Which links are you using? In other words, are they plain HTML links (<a href=""> links), ASP.NET links (<asp:HyperLink>), LinkButtons (<asp:LinkButton>), etc.?
How are you specifying the URL in those links? ASP.NET has a "shortcut" for root directory of the website if you use the tilde (~) character. So, to link to a page on your site called "MyPage.aspx", you might use "~/MyPage.aspx".

Related

Running several web applications from a single domain name on IIS

Supposing I have my main asp.net website hosted at domain.com.
Is it possible to install another website (web app) so that it is accessible via "subfolder": http://www.domain.com/second-app ?
Is there a restriction on what technology the second app can be? Can it be PHP, even though the main site is asp.net?
To make it clearer, as an example:
Main website: http://www.domain.com/
Then I want to install one of the wiki-engines so that it will be accessible like so: http://www.domain.com/wiki
From the technical IIS point of view these 2 will be different websites.
So, is such a setup possible? If so, how? Any web.config settings one should be aware of?
Yes, this is quite common. The second app can be in any language (but since it's IIS it will inherit the "Web.config" settings under the parent app.)
You just have to make sure you install PHP for IIS: https://php.iis.net/
So in IIS to accomplish this.
You will create a site "domain.com"
Right click on that site and click "Add Application"
It's that simple.

Subdomain doesn't show images from root Domain (Drupal)

I have a site up and running using Drupal.I use a web-hosting service, that uses Plesk 12 panel.Recently I decided to add a subdomain for the mobile version of my site.So I created a subdomain inside Plesk, pointed it to www.mydomain.com and named it m.mydomain.com.My desktop site is in httpdocs folder and my mobile version in m.mydomain.com folder.Then I added redirection to my mobile site when a mobile device is detected.
The problem is that m.mydomain.com does not show images because they are uploaded in httpdocs/sites/default/files which is my desktop site.Is there a way to access that folder from my subdomain?I have no access to http config files.Is there a way to do this from .htaccess file of my sub-domain?
*UPDATE
My structure is:
root
-----httpdocs
----------desktop site folder
-----------------desktop site files
----------mobile site folder
-----------------mobile site files
----------images
The best option I can think of is to use the Drupal module Domain Access.
From the module's page:
The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database.
Using that, you should be able to apply a different theme to the subdomain site than what you are doing with your main domain. You could use JavaScript or the like to redirect people to the subdomain.
The second option is that there is already a module called Mobile Tools that allow you to change theme and other settings for mobile devices. The description for that module page is as follows:
The Mobile Tools module provides Drupal developers with some tools to assist in making adjustments to your site based on the visitor's device.
It was mentioned in this question, "How to redirect users to mobile site". However, I must caution you against using the Mobile Tools module as it is only in development, and the last contribution to it was 3 years ago. (Plus they have a big warning on their module page that says "Do not use on production".)
Either of these modules should be able to get you started in the right direction.
Instead of doing a redirect, I would place the images in a folder accessible to both systems. My understanding is right now you have something similar to...
site1/images
site2
If you move your images folder higher in your folder architecture to the same level as site1 and site2 and you update your Public file system path and Private file system path in the media configuration to be that directory it will resolve your issues. Essentially your folders will end up looking like this.
site1/
site2/
images/

Orchard CMS - menu link to network-shared file

I have an Orchard 1.6 site hosted on Windows Server 2012, IIS 8.5, .NET 4.0.
I need to add a link to a network-hosted file into my Orchard menus, where the network share is accessible from my web server - the destination file itself resides on a different server. I put in file://path/to/network/file in the Custom Link menu URL, but the base URL of the site always gets prepended to the link.
E.g., if my base URL is http://example.com, the link becomes http://example.com/file://path/to/network/file, and then .NET does not like the second : in the path - on top of it being the incorrect link. No combination of forward-slashes, backslashes, or other symbols prevents the prepended base URL.
To add another wrinkle to this, the same URL scheme works fine with a slightly different setup: Orchard 1.6, Windows Server 2008, IIS 7.0, .NET 4.0; web server and destination network URL are on the same server.
Is there a way to force Orchard to use the URL as given, without changing it at all? Alternatively, where is the code that constructs the final link?
Using a 'HTML menu item' instead of 'Custom link' to insert raw HTML as a link does work, but that seems like a pretty kludgy workaround; I have to do this for a few dozen links, and I won't necessarily be the one to change them later on.
I've looked into Orchard settings and IIS settings; neither has anything about rewriting links. Changing the base URL on Orchard to match the expected destination server doesn't work (and wouldn't be acceptable long-term). I've also tried hosting a temporary local file (c:\temp\test.txt) but I can't even get that to produce the correct file:// destination on the new setup.
Upgrading to the latest Orchard (1.8.x) is not a feasible solution (if that even ends up being a possible solution).
Edit:
I should clarify that both sites are on an intranet; I'm aware of the security implications associated with file:// links, and the problems with getting various browsers to load them properly, but I want to get the link generation working first.
Edit: problem source
I figured out why link handling was inconsistent between my own sites - I had written a small chunk of Javascript in the first site to strip the application's base URL for any file:// links it encountered. I forgot that it was there and hardcoded to remove only a certain base URL, so when I moved the site to a different hostname, it broke.
So, no inconsistency in Orchard, just my own faulty memory.
Orchard deliberately limits menu links to mailto, tel, http, and https protocols, and excludes all others, such as file and ftp (see navigationmanager.cs). If you want to use other protocols, you will have to use another type of menu item, but please keep in mind that the file protocol is unsafe and is not supported by all browsers, for security reasons (see for example http://kb.mozillazine.org/Links_to_local_pages_do_not_work). Even Internet Explorer has stopped supporting it in the Internet zone since IE6 SP1: http://msdn.microsoft.com/en-us/library/aa767731(v=vs.85).aspx

favicon.ico not supported under Windows IIS

We have a problem under Microsoft IIS. People are not able to request the favicon through the browser. We checked all the coding of the website we are hosting on it and it is all fine. Problem is that the icon file seems to be blocked in general for the outside world:
Icon location: http://www.raakbeleving.nl/favicon.ico (gives 404)
Anybody any clue what could make this happen?
Our hosting provider cannot seem to solve the problem.
Thanks in advance.
See this page for a way to set up the content type in IIS 7.
Here there are a number of additional hints for it..
MS IIS Manager version 1809 includes a MIME type of .ico
**To Clarify the Problem: **
I have my favicon.ico in the root directory of my application which has an alias name of the website. I have run the same html through a number of servers. Each one looks for the favicon.ico, finds it, and uses it.
When you access a website without a favicon.ico, the icon on the browser tab for that site will have a browser default icon. The favicon.ico, when it exists, will replace that tabl icon with a custom one. I have found a lot of sites that discuss how MS IIS does not support favicon.ico.

Orchard CMS Adding a links in HTML widget

I'm trying to add links to pages in the HTML widget.
I'm currently running orchard as a virtual directory, so I can't use '/'. Also since I'm working on a dev site then copying over to a live site, I'm not sure if the site will be running as a virtual directory or from the root.
I've just realised that all links entered via the HTML widget will have a problem, since you can't use '~', also it looks like the image links are fixed, so deploying to a different location won't work ie. from localhost\dev to localhost\live
Any ideas?
If you're entering it from the html editor, you don't have any choice but to use a rooted path (/foo). Sure, it can cause problems if you then publish from a vdir into a site without a vdir, but that's how it for now. We're looking at solutions but in the meantime your best bet is to have a dev site that is as close as possible to the production setup.
As pointed out by randompete on codeplex, another solution could be implementing your own IHtmlFilter. I wrote a simple implementation which you can find here: http://orchard.codeplex.com/discussions/279418
It basically post-processes the BodyPart text by replacing all occurences of urls starting with ~/ with a resolved url (using the UrlHelper.Content() method)
If you need to display a link pointing to a static resource, you can use:
#Html.Link(string textlink, string url)
But Html.Link doesn't supports application relatives urls (~/[...] ones)
if you need only the href (as for an img ). It supports ~/ urls.
src='#Href(string url)'
If you need to display a link to an action
#Html.ActionLink(...) <-- lots of overloads.

Resources