0

I'm currently working on an MVC4 project, that is being deployed to an IIS6 hosting environment.


I am using Html.ActionLink() to generate links on my page.

eg:

@Html.ActionLink("Home Link", "Index", "Admin")

When I run the application locally (ie hitting http://localhost:yyy), the link is generated fine:

<a href="/Admin/Index">Home Link</a>

When I run it in the production environment however:

<a href="">Home Link</a>

As you can see, the link does not have a href generated for it.


I thought it might be an issue with routing, but when I try to visit a page in the browser: admin/edit/45, or one using a custom route binding: sf/24, both of these work fine; they direct me to the page I expect.


I'm pretty out of ideas, and not sure on how to resolve.

Any help, would be greatly appreciated.

Thanks,


I've added a bounty to this, in the hope that it might help get an answer. I suspect this problem could help others, as I don't seem to be doing anything too groundbreaking.


UPDATE 24/09/14

This is being developed in VS2010 SP1, using the built-in web server (Cassini?).

I am then publishing (using the in-built options of Visual Studio) to the server, which is running IIS6.

The directory structure contains something similar to:

App_Start
Assets
Classes
Content
Controllers
DomainModel
Scripts
Services
SharedAssets
ViewModels
Views

(ie. nothing in there matches the names of any links).

On top of this, bundling seems to work. eg: @Scripts.Render("~/bundles/adminjs")

Using this (VB) Razor:

@Html.ActionLink("View", "Display", "Form", New With { .id = 72 }, Nothing)
<br />
@Html.RouteLink("View", "Default", new with { .controller = "Form", .action = "Display", .id = 72 })

I get the following output..

In VS10/Chrome (local):

<a href="/Form/Display/72">View</a>
<br>
<a href="/Form/Display/72">View</a>

In IIS6/Chrome (server):

<a href="">View</a>
<br>
<a href="">View</a>

..adding more to the mystery of it not picking up the routes..

askrich
  • 598
  • 5
  • 20
  • are you hosted site as a virtual directory? – Chamika Sandamal Sep 11 '14 at 08:56
  • No, the site is hosted as an application within IIS – askrich Sep 11 '14 at 09:21
  • is this the root site? – Chamika Sandamal Sep 11 '14 at 09:25
  • There are other sites on the server, but access to 'index' is through http://xxxx/, and not http://xxxx/yy – askrich Sep 11 '14 at 09:27
  • I've had a similar issue before, what does the file structure look like within your deployment folder? – loxdog Sep 18 '14 at 15:37
  • Are you also developing locally in an IIS6 environment, rather than IIS7? I had all manner of problems trying to redeploy from one to the other. – Rob Wilkins Sep 18 '14 at 18:57
  • First try change the `@Html.ActionLink(...)` to `@Html.RouteLink("Home Link", "Default", new { controller = "Admin", action = "Index" })` and see if anything changed. It can help us make better guess on where the problem is. – tweray Sep 18 '14 at 19:23
  • I've updated my answer with findings from these examples. Help would be greatly appreciated :) – askrich Sep 24 '14 at 13:47
  • Can you please post the contents of your route configurations? – mreyeros Sep 24 '14 at 18:56
  • It seems there is a problem with RouteValueDictionary when it is hosted in production based on the source code: http://aspnetwebstack.codeplex.com/SourceControl/latest#src/Microsoft.Web.Mvc/LinkExtensions.cs I would investigate further on this. Hopefully I can help you. – Hatjhie Sep 25 '14 at 06:17

2 Answers2

1

You may want to take a look at this SO to see if you are experiencing the same issue regarding the way that your routes and default routes are defined.

Community
  • 1
  • 1
mreyeros
  • 4,359
  • 20
  • 24
  • Following one of the answers in this post has lead me to be able to partially resolve my issue, I shall now investigate to solve the problem fully. When I used a "simple" route (with only one optional parameter) it worked perfectly. Thanks! – askrich Sep 25 '14 at 09:49
0

IIS 6 does not support app-pools with Integrated mode. Here is a guide to how you can get IIS to route the requests to your ASP.NET MVC application. More guiding here.

Here is a great answer comparing the two modes, Classic and Integrated.

Community
  • 1
  • 1
Mads
  • 444
  • 1
  • 5
  • 15
  • Thanks for this, I'm struggling to see if this is the problem though. When I directly access the page (eg `/admin/edit/72`) the expected page displays and works. What doesn't seem to be working is the actual generation of these links. – askrich Sep 24 '14 at 14:35
  • Ok, then these things are not connected. Strange stuff. – Mads Sep 24 '14 at 14:40