谁会用URL ROUTING 做图片文件名的重写?
请问高手有没有比以下更好的办法:十分感谢回贴!我原本是用:global.asax里面加入:
void Application_Start(object sender, EventArgs e)
{
//在应用程序启动时运行的代码
RegisterRoutes(RouteTable.Routes);
}
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("myid", "image/{filename}/{imgtitle}.jpg", "~/imageback.aspx");
}
调用imageback.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class imageback : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string imgfile = Page.RouteData.Values["filename"].ToString();
string imgpath = @"~/file/sfile/" +imgfile +".jpg";
Response.Clear();
Response.ContentType = "image/png";
Response.WriteFile(imgpath);
Response.End();
}
} --------------------编程问答-------------------- 不要沉下去呀,有没有帮忙解答一下,十分感谢!
补充:.NET技术 , 非技术区