MVC3 Web应用程序直接在index.cshtml路由 [英] Mvc3 web app routing directly on index.cshtml

查看:174
本文介绍了MVC3 Web应用程序直接在index.cshtml路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建和主机nvc3 Web应用程序
现在的问题是,当我打开我的 www.abc.com
它是开放的MVC Web应用程序的index.cshtml即首页

I have created and host nvc3 web app now problem is when I open my www.abc.com it is opening index.cshtml i.e home page of mvc web app

但我不想当我打开那个是开放 www.abc.com
我已经叫一个静态页面的index.htm 应该是开放的第一个

but I dont want that to be open when I open www.abc.com I have one static page called index.htm should be open first

在MVC3的Global.asax code:

in mvc3 Global.asax code:

  public static void RegisterRoutes(RouteCollection routes)
        {
            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
            );

        }

我怎样才能呈现到 http://www.abc.com/mypage.html
我应该怎么请帮助。

How can I render to http://www.abc.com/mypage.html ? what should I please help.

推荐答案

ashuthinks,

ashuthinks,

根据对这一问题的修改意见。如果你只是想显示没有链接在敷设渠道页面类型,那么你可以修改的web.config 并添加 app_offline.htm 文件。这里的这些变化将是什么样子:

Based on your revised comments for the question. If you just want to show the 'Under contruction' type page with no links, then you can modify the web.config and add an app_offline.htm file. here's what those changes would look like:

的web.config(梗概):

web.config (bare bones):

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
</configuration>

app_offline.htm:

app_offline.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Your site title</title>
</head>
<body>
  <div>
    <span>Your Company name</span>
    <h1>Sorry, server maintenance in progress </h1> 
    <h2>Please contact <a href="mailto:mycontact@mycompany.com">John Doe</a> on 000 123 456789 for further information</h2>
  </div>
</body>
</html>

当你需要把现场直播,只需将上述文件重命名为 web.config_offline app_offline.htm_offline ,把你的'正常'的web.config中发挥作用。当然也有很多方法对皮肤这只猫但这与我工作过的previous项目运作良好。

when you need to put the site live, simply rename the above files to web.config_offline and app_offline.htm_offline and bring your 'normal' web.config into play. There are of course many ways to skin this cat but this has worked well with previous projects that I've worked on.

请参阅:

http://weblogs.asp.net/scottgu/存档/ 2006/04/09 / 442332.aspx

了解更多详情。

这篇关于MVC3 Web应用程序直接在index.cshtml路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆