易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net 等比例生成上传图片的高质量缩略图的方法

方法1
HttpFileCollection files   = HttpContext.Current.Request.Files;
//我设置的大小不超过A4纸的缩略图
int newWidth=620;
int newHeight=880;
System.Drawing.Image img = null;
            
for(int iFile = 0; iFile < files.Count; iFile++)
{
     ///检查文件扩展名字
     HttpPostedFile postedFile = files[iFile];
     string fileName, fileExtension;
     fileName = System.IO.Path.GetFileName(postedFile.FileName);
     if (fileName != "")
     {
         fileExtension = System.IO.Path.GetExtension(fileName);
         string name=DateTime.Now.ToString("yyyyMMddHHmmssffffff")+iFile+fileExtension;
         string filePath=System.Web.HttpContext.Current.Request.MapPath(@"UpdatePic/") + name;
                        
         if (fileExtension.ToLower()==".jpg" || fileExtension.ToLower()==".gif" || fileExtension.ToLower()==".png")
         {
             //图片大小限制在1K到2M之间
             if(postedFile.ContentLength>=1024 && postedFile.ContentLength<=20480000 && postedFile.ContentType.ToString().ToLower().IndexOf("image") >= 0)
             {
                 img = System.Drawing.Image.fromStream(postedFile.InputStream);
       &nb


相关文档:

ASP.NET页面传值_第三篇_ViewState

+++ 页面代码如下:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
+++ 后台代码如下:
protected void Butto ......

ASP.NET页面传值_第五篇_Application

+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
  Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{  }
void Application_Error(object sender, EventArgs ......

asp.net生成静态页的方法





1、直接将页面内容存在变量中后输出: 
 StringBuilder IndexContentResult= new StringBuilder(); //存放输出页面的HTML 
 IndexContentResult.Append("<html>\n"); 
 IndexContentResult.Append(&qu ......

新手跟着学Asp.net MVC2 Controller

上次我们说到了 route 路由的功能,整个mvc运行过程:
Route(路由) --> Controller(控制器)-->action(方法)
这次我们要说的就是 controller 控制器 和 action:
控制器的作用就是:当一个 Request 来的时候,首先Route 解析 找到了 对应 控制器,控制器再根据  action 决定给我们返回什么样的内容。如:
代码 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号