问题asp.net 3.5路由地址 [英] Problem asp.net 3.5 routing address

查看:81
本文介绍了问题asp.net 3.5路由地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前做路由服务器的时候.我有问题.
如果 http://myweb.com/news/22 .aspx
没问题 但是
如果 http://myweb.com/news/22 问题:404-找不到文件或目录.

id执行此操作:

global.asax

I used to do when the routing server. I have a problem.
No problem if http://myweb.com/news/22.aspx
But
If http://myweb.com/news/22 problem: 404 - File or directory not found.

id do this :

global.asax

void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
         routes.Add("News", new Route("News/{ID}",new CustomRouteHandler("~/News/News.aspx")));
    }



CustomRouteHandler.cs类:



CustomRouteHandler.cs class :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Routing;
using System.Web.Compilation;

public class CustomRouteHandler : IRouteHandler
{
    public CustomRouteHandler(string virtualPath)
    {
        this.VirtualPath = virtualPath;
    }

    public CustomRouteHandler()
    {
    }

    public string VirtualPath { get; private set; }

    public IHttpHandler GetHttpHandler(RequestContext
          requestContext)
    {
        var page = BuildManager.CreateInstanceFromVirtualPath
             (VirtualPath, typeof(Page)) as IHttpHandler;
        return page;
    }
}



web.config:



web.config :

<add assembly="System.Web.Routing, Version=3.5.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>


<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing, Version=3.5.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" />


<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler,System.Web, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />



链接:



link :

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/news/22" Text="News"></asp:HyperLink>





在本地没有问题,但是服务器错误
即使.Html或.jsp我也使用
是什么问题?





in local no problem , but server error
Even when .Html or .jsp I use
What is the problem?

推荐答案

可以确认服务器上是否安装了asp.net MVC.
Can you confirm if asp.net MVC is installed on the server.


这篇关于问题asp.net 3.5路由地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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