3

Currently I have a .net web forms app that works correctly under the root site www.mydomain.com

Now, what I'm trying to do is to deploy the MVC.net mobile version of the app above and make it respond to: www.mydomain.com/mobile

So I copied the mobile app to inetpub\mobile (the parent web forms app resides at inetpub\myapp, i.e., they are located on sibling folders).

Then, I went to IIS 7 and created a new application for the mobile app under my www.mydomain.com site:

IIS configuration

When I test it, the app loads fine but when I click on a link, for example /mobile/Places/Places, the requested URL seems to be handled by web forms instead of MVC's routing since the error adds the aspx extension:

Requested URL: /mobile/Places/Places.aspx

Error message

It seems to me that even though the apps are located on different folders the mobile version is somehow inheriting settings from the web forms app (parent).

The mobile app actually works fine when I create a subdomain mobile.mydomain.com but it really bugs me I can't find away to make it work on www.mydomain.com/mobile.

I even tried wrapping the system.web and system.webServer tags in the mobile app config file with location elements setting inheritInChildApplications to false but no luck:

<location path="." inheritInChildApplications="false">
 <system.web>

<location path="." inheritInChildApplications="false">
 <system.webServer>

Any ideas?

2
  • Are you sure that mvc is installed on that server? Commented May 28, 2013 at 21:09
  • Yes, I downloaded the installer and said it was installed already. Then I went to Programs and found Microsoft ASP.NET MVC from 2,3 and 4 Commented May 28, 2013 at 21:37

2 Answers 2

1

It turns out that the config file of the parent web forms application had a URL rewrite element, something like this:

<rewrite>
    <rules>
        <clear />
        ...
        <rule name="RewriteASPX" enabled="true">
            <match url="^([a-zA-Z0-9/_. -]+)$" ignoreCase="false" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v)$" negate="true" /> 
            </conditions>
            <action type="Rewrite" url="{R:1}.aspx" />
        </rule>
    </rules>
</rewrite>

After I added an exception for the mobile site (rule with stopProcessing="true") it started to work just fine.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you considered doing a subdomain for your mobile application? Nested web.configs can be hell to manage especially if the routing rules are different between the parent and child application. If someone knows of how to make the web.configs behave together, then I'd be interested to see how it's done. However, using a subdomain, you could create a new website and add it like so to IIS: m.mydomain.com

This website will run independently of the main website since it won't be a child application to the main website. You will need to add a record to your DNS settings that points to the same IP address as your main domain name and just configure the virtual host through IIS.

1 Comment

Yes, I didn't explain my self well but yes I tried that option and it worked fine. I may just go for it. But I really wanted to find out why it wouldn't work the other way. To make things more interesting I just found out that our production environment is setup the way I'm trying to do. The only difference is that they are using MVC3 (not 4)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.