ASP.NET开源MVC框架Vici MVC(一)配置

asp.net开源mvc框架 Vici的最大特征是支持ASP.NET2.0和IIS不需要额外的设置

例子的下载地址http://viciproject.com/wiki/projects/mvc/Download

现在大把大把的ASP.NET MVC框架都需要 iis进行额外的设置 而vici却不需要,为什么呢

看看他的配置文件Web.config

<?xml version="1.0"?>
<configuration>

    <appSettings>
      <add key="Mvc.ApplicationClass" value="ViCiCore.Application,ViCiCore" />
      <add key="Mvc.TemplatePath" value="Content/templates" />
    </appSettings>
  
    <connectionStrings />
    <system.web>
        <compilation debug="true">
        </compilation>

      <globalization  requestEncoding="utf-8" fileEncoding="utf-8" />
      <httpModules>
        <add name="MvcModule" type="Vici.Mvc.HttpModule, Vici.Mvc" />
      </httpModules>

      <httpHandlers>
        <add verb="*" type="Vici.Mvc.MVCHandler, Vici.Mvc" path="ProMesh.axd" />
      </httpHandlers>
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Windows" />
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

    </system.web>


  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <directoryBrowse enabled="true" />

    <modules runAllManagedModulesForAllRequests="true">
      <add name="MvcModule" type="Vici.Mvc.HttpModule, Vici.Mvc" />
    </modules>

    <handlers>
      <add name="MvcHandler" preCondition="integratedMode" verb="*" path="ProMesh.axd" type="Vici.Mvc.MVCHandler, Vici.Mvc" />
    </handlers>

  </system.webServer>

</configuration>

 

 

 

注意appSettings节点,httpModules节点,httpHandlers节点

    <appSettings>
      <add key="Mvc.ApplicationClass" value="ViCiCore.Application,ViCiCore" />
      <add key="Mvc.TemplatePath" value="Content/templates" />
    </appSettings>

     <httpModules>
        <add name="MvcModule" type="Vici.Mvc.HttpModule, Vici.Mvc" />
      </httpModules>

      <httpHandlers>
        <add verb="*" type="Vici.Mvc.MVCHandler, Vici.Mvc" path="ProMesh.axd" />
      </httpHandlers>

可见 vici是基于httpModules和httpHandlers的

<appSettings>节点中 第一个对应一个类 第二个对应模板的文件夹

看看ApplicationClass这个类有设么东西

 public static class Application
    {
        public static void Init()
        {

            WebAppConfig.Router.AddDefaultRoutes(".aspx"); // ".aspx"
          
        }
    }

 

是一个初始化的,用来初始化默认路由 和 对什么类型的后缀名进行路由 选择.aspx就不用iis而外的设置

默认的路由和微软的mvc差不多 有以下几种

URLControllerActionParameters
~/{controller}/{action}/{id}{controller}{action}id = {id}
~/{controller}/{action}{controller}{action} 
~/{controller}{controller}Run 

vici的配置还是蛮简单的吐舌笑脸

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值