上次我们说到了 route 路由的功能,整个mvc运行过程:
Route(路由) --> Controller(控制器)-->action(方法)
这次我们要说的就是 controller 控制器 和 action:
控制器的作用就是:当一个 Request 来的时候,首先Route 解析 找到了 对应 控制器,控制器再根据 action 决定给我们返回什么样的内容。如:
代码
public class MyControllerController : Controller
{
public ActionResult MyAction(DateTime dt)
{
ContentResult cr = new ContentResult();
cr.Content = "MyController's MyAction is Workded!" + dt.ToString("yyyy年MM月dd日");
return cr;
......
前面我们说过了 控制器(controller) 和方法(action)
本次要说的就是 View以及和控制器(controller)、方法(action)之间的关系;
大家都知道 MVC中的 V 就是View 的意思,就是 呈现给用户的界面,以往的asp.net项目中叫 webform,以前做asp.net的时候就是在工具箱里面拖控件出来,
然后简单的排版一下就ok了,大多数用的服务器控件来完成,然而我们会发现 在生成的页面中包含大量的 hidden字段,
微软就是通过这边的hidden字段的内容来维护 每个服务端控件状态的,如果页面很多服务端控件的话整个页面就显得很臃肿。
而mvc 推出后,就不再推荐使用服务端控件(当然是可以使用的),而用传统的手写 html来完成(似乎又回到过去了?呵呵)。
首先我们说一下 View 和 Controller、action之间的关系:
Controller -->Action -->View
前几篇文章说过 如何从 我们输入的 URL,找到route 再找到 controller再找到对应的action,并且说过了 action 的几种返回类型。
今天的主角就是 View 类型:
public ActionResult Index()
{
&nbs ......
第一种适用于没有建立虚拟路径的项目,而且项目也不大的情况下,直接打断点,之后点击F5运行。
第二种适用于建立虚拟路径的项目,打好断点,之后选择调试->附加到进程->选择aspnet_wp.exe,之后打开浏览器,打开页面,到有断点的地方会自动跟踪进去!~
注:有的操作系统可能找不到aspnet_wp.exe 可能存在ccc.exe之类的,可选择附加! ......
方法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(@"U ......
1. aspx页面端代码:
<div class="gv-footer">
<asp:LinkButton ID="btFirstPage" runat="server" CommandArgument="first" OnClick ="PagerButton_Click">首页</asp:LinkButton>
<asp:LinkButton ID="btPrevPage" runat="server" CommandArgument="prev" OnClick ="PagerButton_Click">上一页</asp:LinkButton>
<asp:LinkButton ID="btNextPage" runat="server" CommandArgument="next" OnClick ="PagerButton_Click">下一页</asp:LinkButton>
<asp:LinkButton ID="btLastPage" runat="server" CommandArgument="last" OnClick ="PagerButton_Click">尾页</asp:LinkButton>
页码:
<asp:Label ID="lbCurrentPage" runat="server" ForeColor="Blue"></asp:Label>
& ......
在部署水晶报表时主要遇到支持组件的问题。
首先,需要在服务器上需要安装“CRRedist2008_x86.msi”和汉化包“CRRedist2008_x86_chs.msi”。
vs.net 2008,在这个目录
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5
vs.net 2005,在这个目录
C:\Program Files\Microsoft Visual Studio 8\ReportViewer
vs.net 2008,在这个目录
C:\Program Files\Microsoft Visual Studio 9.0\ReportViewer
接着,安装好了CRRedist2005_x86.msi 后,系统会在服务器的网站中建立一个aspnet_client文件夹。此文件夹中含有水晶报表的相关控件及图标。把CrystalReportWebFormViewer4文件夹拷贝到自己的虚拟目录的根文件夹下的aspnet_client\system_web\2_0_50727就可以正常显示水晶报表的工具栏图标了。
CrystalReportWebFormViewer4在此目录下
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETClientFiles
--------------------------暂留问题------------------------
这三个DLL在发布的网站Bin文件夹中未发现,不一定有用
将下面几个dll拷贝到/bin下,注意版本号
microsoft.reportviewer.common.dll
mi ......