AS.NET-ベース12、Request
5237 ワード
1、パス識別子。
<asp:HyperLink runat="server" NavigateUrl="~/a/b.aspx"></asp:HyperLink>
Response.Write("<a href='"+VirtualPathUtility.ToAbsolute("~/a/b.aspx"));
3、RequestはPage類の属性ですので、asxではcontext.Requestを使います。
context.Response.ContentType = "image/JPEG";
string fullpath = HttpContext.Current.Server.MapPath("IMG_5433.JPG");
using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(fullpath))
{
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
using (System.Drawing.Font font = new System.Drawing.Font(" ", 30))
{
if (context.Request.UrlReferrer == null)
{
g.Clear(System.Drawing.Color.White);
g.DrawString(" ", font, System.Drawing.Brushes.Red, 0, 0);
}
else if(context.Request.UrlReferrer.Host!="localhost")
{
g.DrawString(" ", font, System.Drawing.Brushes.Red, 0, 0);
}
bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}