Discussion:
Why can't I just set the default document :-(
(too old to reply)
Richard Maher
2015-11-30 12:58:08 UTC
Permalink
Hi,

I have been using MVC for a while and when creating projects would opt
for (VS2012) ASP.NET MVC 4 Basic. This all worked well and when I
published the Project I would get a lovely aspnet_client folder and
everything else under the project name folder.

Now when I opted for Web API under MVC I don't get that folder footprint
and, for the life of me, cannot get a simple Default Document to work in
IIS :-(

Yes I have tried: -

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id =
UrlParameter.Optional } // Parameter defaults
);


and added routes.IgnoreRoute("");

but I simply cannot get IIS to say a simple "Here is what to show in the
absence of a explicit document request".

Recap: - It works with MVC Basic. Doesn't work with MVC Web API. This
may be coincidence but erstwhile I cannae see a difference.

What the hell do you have to do to get a Web Server to serve up a
default file?

Cheers Richard Maher
Arne Vajhøj
2015-12-06 20:04:05 UTC
Permalink
Post by Richard Maher
I have been using MVC for a while and when creating projects would opt
for (VS2012) ASP.NET MVC 4 Basic. This all worked well and when I
published the Project I would get a lovely aspnet_client folder and
everything else under the project name folder.
Now when I opted for Web API under MVC I don't get that folder footprint
and, for the life of me, cannot get a simple Default Document to work in
IIS :-(
Yes I have tried: -
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id =
UrlParameter.Optional } // Parameter defaults
);
and added routes.IgnoreRoute("");
but I simply cannot get IIS to say a simple "Here is what to show in the
absence of a explicit document request".
Recap: - It works with MVC Basic. Doesn't work with MVC Web API. This
may be coincidence but erstwhile I cannae see a difference.
What the hell do you have to do to get a Web Server to serve up a
default file?
This would make controller Home and action Index the default.

Are you asking for how to make the default a static HTML page not going
through any controller+action?

Arne
Richard Maher
2015-12-07 00:05:09 UTC
Permalink
Post by Arne Vajhøj
Post by Richard Maher
I have been using MVC for a while and when creating projects would opt
for (VS2012) ASP.NET MVC 4 Basic. This all worked well and when I
published the Project I would get a lovely aspnet_client folder and
everything else under the project name folder.
Now when I opted for Web API under MVC I don't get that folder footprint
and, for the life of me, cannot get a simple Default Document to work in
IIS :-(
Yes I have tried: -
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id =
UrlParameter.Optional } // Parameter defaults
);
and added routes.IgnoreRoute("");
but I simply cannot get IIS to say a simple "Here is what to show in the
absence of a explicit document request".
Recap: - It works with MVC Basic. Doesn't work with MVC Web API. This
may be coincidence but erstwhile I cannae see a difference.
What the hell do you have to do to get a Web Server to serve up a
default file?
This would make controller Home and action Index the default.
Are you asking for how to make the default a static HTML page not going
through any controller+action?
Yes please.

I thought routes.IgnoreRoute(""); would do it. (Actually, it is now a
.ASPX file if that makes a difference.)

BTW I started with NO routing information in the Global and I have the
same routing config in another App that has no problem with a default
page. Although I've given up on any difference in MVC templates. I've
tried all of them and cannot get a default page to work.

I'm guessing the one that works somehow knows to look in the root/home
directory but the others are perhaps looking at a lower level?
Post by Arne Vajhøj
Arne
Arne Vajhøj
2015-12-07 01:08:14 UTC
Permalink
Post by Richard Maher
Post by Arne Vajhøj
Are you asking for how to make the default a static HTML page not going
through any controller+action?
Yes please.
I thought routes.IgnoreRoute(""); would do it. (Actually, it is now a
.ASPX file if that makes a difference.)
There are supposedly 3 ways to do this.

1)

routes.IgnoreRoute("");

2)

public ActionResult Index()
{
return Redirect(Url.Content("~/index.html"));
}

(well this do go through controller and action, but ...)

3)

protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/")
Context.RewritePath("index.html");
}

#1 does not work for you. I worked for me when I tested in 2013.
I don't know why it does not work for you.

But that leaves #2 and #3.

I would say that #2 is the MVCish way and #3 is the hackish way.

Your choice.

Arne
Richard Maher
2015-12-07 01:13:12 UTC
Permalink
Post by Arne Vajhøj
Post by Richard Maher
Post by Arne Vajhøj
Are you asking for how to make the default a static HTML page not going
through any controller+action?
Yes please.
I thought routes.IgnoreRoute(""); would do it. (Actually, it is now a
.ASPX file if that makes a difference.)
There are supposedly 3 ways to do this.
1)
routes.IgnoreRoute("");
2)
public ActionResult Index()
{
return Redirect(Url.Content("~/index.html"));
}
(well this do go through controller and action, but ...)
3)
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/")
Context.RewritePath("index.html");
}
#1 does not work for you. I worked for me when I tested in 2013.
I don't know why it does not work for you.
But that leaves #2 and #3.
I would say that #2 is the MVCish way and #3 is the hackish way.
Your choice.
Arne
Thanks Arne.

I try 1 again and 2 but I can't help thinking that it is a relative URI
problem and knowing in which folder/top the files live.

Cheers Richard
Arne Vajhøj
2015-12-07 01:19:40 UTC
Permalink
Post by Richard Maher
Post by Arne Vajhøj
Post by Richard Maher
Post by Arne Vajhøj
Are you asking for how to make the default a static HTML page not going
through any controller+action?
Yes please.
I thought routes.IgnoreRoute(""); would do it. (Actually, it is now a
.ASPX file if that makes a difference.)
There are supposedly 3 ways to do this.
1)
routes.IgnoreRoute("");
2)
public ActionResult Index()
{
return Redirect(Url.Content("~/index.html"));
}
(well this do go through controller and action, but ...)
3)
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/")
Context.RewritePath("index.html");
}
#1 does not work for you. I worked for me when I tested in 2013.
I don't know why it does not work for you.
But that leaves #2 and #3.
I would say that #2 is the MVCish way and #3 is the hackish way.
Your choice.
I try 1 again and 2 but I can't help thinking that it is a relative URI
problem and knowing in which folder/top the files live.
I had index.html in the root dir (next to web.config etc.).

Arne
Arne Vajhøj
2015-12-07 01:21:18 UTC
Permalink
Post by Arne Vajhøj
Post by Richard Maher
Post by Arne Vajhøj
Post by Richard Maher
Post by Arne Vajhøj
Are you asking for how to make the default a static HTML page not going
through any controller+action?
Yes please.
I thought routes.IgnoreRoute(""); would do it. (Actually, it is now a
.ASPX file if that makes a difference.)
There are supposedly 3 ways to do this.
1)
routes.IgnoreRoute("");
2)
public ActionResult Index()
{
return Redirect(Url.Content("~/index.html"));
}
(well this do go through controller and action, but ...)
3)
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/")
Context.RewritePath("index.html");
}
#1 does not work for you. I worked for me when I tested in 2013.
I don't know why it does not work for you.
But that leaves #2 and #3.
I would say that #2 is the MVCish way and #3 is the hackish way.
Your choice.
I try 1 again and 2 but I can't help thinking that it is a relative URI
problem and knowing in which folder/top the files live.
I had index.html in the root dir (next to web.config etc.).
I think that is the only place where #1 will work.

For #2 and #3 you can specify a dir (just make sure that the dir
is copied to output dir.

Arne
Richard Maher
2015-12-09 12:22:35 UTC
Permalink
Post by Arne Vajhøj
I think that is the only place where #1 will work.
For #2 and #3 you can specify a dir (just make sure that the dir
is copied to output dir.
Arne
I think it's to do with the last site that worked having an
"application" within the web-site and the other one just having the \bin
etc. and an application-less web-site.

So I guess I'm looking at a publishing problem? I think last time I did
a right-click convert-folder-to-application.

The working one is just drag-n-drop files and the other is web-deploy.

How do you deploy primarily mvC apps and then set up a default page?

Cheers Richard Maher
Arne Vajhøj
2015-12-10 01:00:05 UTC
Permalink
Post by Richard Maher
Post by Arne Vajhøj
I think that is the only place where #1 will work.
For #2 and #3 you can specify a dir (just make sure that the dir
is copied to output dir.
I think it's to do with the last site that worked having an
"application" within the web-site and the other one just having the \bin
etc. and an application-less web-site.
So I guess I'm looking at a publishing problem? I think last time I did
a right-click convert-folder-to-application.
The working one is just drag-n-drop files and the other is web-deploy.
Did you try #2 or #3?
Post by Richard Maher
How do you deploy primarily mvC apps and then set up a default page?
I don't.

:-)

Arne

Loading...