在ASP.NET 4.0中的虚荣网址/网址重写 [英] vanity url/ url rewriting in asp.net 4.0

查看:66
本文介绍了在ASP.NET 4.0中的虚荣网址/网址重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为所有在Facebook中注册的会员创建公开个人资料:facebook/username重定向到用户的个人资料,我该如何获取?个人资料页面可能看起来像这样www.example.com/users.aspx?user=john我想通过输入www.example.com/john来获得此信息.我正在使用asp.net 4.0,visual studio 2010,sqlserver server 2005 (linq)
提前谢谢..

I am trying to create public profile for all members who sign up like in facebook: facebook/username redirects to user''s profile how can i get this? profile page may look like this www.example.com/users.aspx?user=john i want to get this by typing www.example.com/john.. i am using asp.net 4.0, visual studio 2010, sqlserver server 2005 (linq)
thanx in advance..

推荐答案



试试这个


Hi,

Try this


using System;
using System.Web.Routing;

namespace UrlRewriting
{
    public class Global : System.Web.HttpApplication
    {

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

        public static void RegisterRoutes(RouteCollection routeCollection)
        {
            routeCollection.MapPageRoute("RouteForCustomer", "{Id}", "~/User.aspx");
        }

    }
}


这篇关于在ASP.NET 4.0中的虚荣网址/网址重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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