由default.designer.cs想到的。

本文详细对比了ASP.NET应用程序(WebApplication)与Website编程模型的优缺点,包括编译速度、程序集生成、项目管理、代码管理、团队构建支持、代码检查等功能。同时介绍了两种模型之间的相互转换方法。
web site是新建一个网站,web application是asp.net应用程序,大体上二者没太大区别。因为asp.net应用程序是你要在VS2005打了sp1补丁的时候才有的。 我还是用的VS2005,不过web site好像和web application不能自由转化吧,用web application打开web stie项目,好像会自动转化,反之好像不行。

.designer.cs 是利用 partial class 特性,由设计器产生的一个文件,用于保存页面中控件的对应定义。就像winform里面项目中文件有designer.cs一样。

下面是一些比较
WebApplication编程模型的优点: 

●网站编译速度快,使用了增量编译模式,仅仅只有文件被修改后,这部分才会被增量编译进去。 

●生成的程序集 
WebSite:生成随机的程序集名,需要通过插件WebDeployment才可以生成单一程序集 
WebApplication:可以指定网站项目生成单一程序集,因为是独立的程序集,所以和其他项目一样可以指定应用程序集的名字、版本、输出位置等信息 

●可以将网站拆分成多个项目以方便管理 

●可以从项目中和源代码管理中排除一个文件 

●方便的支持VSTS的Team Build方便每日构建 

●更强大的代码检查功能,并且检查策略受源代码控制 

●可以对编译前后进行自己规定的处理 

●对App_GlobalResources 的Resource强类支持(网上说的,还没有了解过) 

●直接升级使用VS2003构建的大型系统 



WebSite编程模型的优点: 

●动态编译该页面,马上可以看到效果,不用编译整个站点(主要优势) 

●同上,可以使错误的部分和使用的部分不相干扰(可以要求只有编译通过才能签入) 

●可以每个页面生成一个程序集(一般不会采用这种方式) 

●可以把一个目录当做一个Web应用来处理,直接复制文件就可以发布,不需要项目文件(适合小站点) 

●可以把页面也编译到程序集中(应该用不到,而且WebApplication也可以通过WebDeployment插件来实现) 


两种编程模型的互相转换: 

VS2005 SP1内置了转换程序,可以非常方便的从WebSite转换到WebApplication 
只需要复制文件,右键执行“转换为Web应用程序”即可。 

未查到有专门的反向转换工具,但比较后发现如果转换也非常简单。 
删除所有*.designer.cs 
将*.aspx、*.ascx、*.master页面文件中的 Codebehind="******.aspx.cs" 批量替换成 CodeFile="******.aspx.cs" 

这样就可以转换回来了
严重性 代码 说明 项目 文件 行 禁止显示状态 错误 CS0246 未能找到类型或命名空间名“ListBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 9 活动 错误 CS0246 未能找到类型或命名空间名“Button”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 6 活动 错误 CS0246 未能找到类型或命名空间名“PictureBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 7 活动 错误 CS0246 未能找到类型或命名空间名“Label”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 8 活动 错误 CS0246 未能找到类型或命名空间名“Label”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 10 活动 错误 CS0246 未能找到类型或命名空间名“PictureBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 11 活动 错误 CS8957 语言版本 7.3 中的条件表达式无效,因为在“Rectangle”和“<null>”之间未找到通用类型。如需使用目标类型转换,请升级到语言版本 9.0 或更高版本。 QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.cs 69 活动 给出修改后的完整代码
10-12
1> 请考虑使用 app.config 将程序集“System.Memory, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”从版本“4.0.1.1”[]重新映射到版本“4.0.1.2”[D:\vs\GoodsWebService\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll],以解决冲突并消除警告。 1> 请考虑使用 app.config 将程序集“System.Runtime.CompilerServices.Unsafe, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”从版本“4.0.4.1”[]重新映射到版本“6.0.0.0”[D:\vs\GoodsWebService\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll],以解决冲突并消除警告。 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3247: 发现同一依赖程序集的不同版本间存在冲突。在 Visual Studio 中,请双击此警告(或选择此警告并按 Enter)以修复冲突;否则,请将以下绑定重定向添加到应用程序配置文件中的“runtime”节点: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Memory" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" /><bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /></dependentAssembly></assemblyBinding> 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(27,13,27,33): error CS0103: 当前上下文中不存在名称“lblSingleGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(28,13,28,30): error CS0103: 当前上下文中不存在名称“lblAllGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(29,13,29,25): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(37,27,37,37): error CS0103: 当前上下文中不存在名称“txtGoodsId” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(39,13,39,33): error CS0103: 当前上下文中不存在名称“lblSingleGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(78,17,78,37): error CS0103: 当前上下文中不存在名称“lblSingleGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(87,17,87,37): error CS0103: 当前上下文中不存在名称“lblSingleGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(92,13,92,33): error CS0103: 当前上下文中不存在名称“lblSingleGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(137,17,137,34): error CS0103: 当前上下文中不存在名称“lblAllGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(141,17,141,34): error CS0103: 当前上下文中不存在名称“lblAllGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(146,13,146,30): error CS0103: 当前上下文中不存在名称“lblAllGoodsResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(155,28,155,40): error CS0103: 当前上下文中不存在名称“txtGoodsName” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(158,13,158,25): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(162,31,162,39): error CS0103: 当前上下文中不存在名称“txtPrice” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(164,13,164,25): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(168,27,168,35): error CS0103: 当前上下文中不存在名称“txtStock” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(170,13,170,25): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(174,32,174,46): error CS0103: 当前上下文中不存在名称“txtPutawayDate” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(200,25,200,37): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(207,25,207,37): error CS0103: 当前上下文中不存在名称“txtGoodsName” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(208,25,208,33): error CS0103: 当前上下文中不存在名称“txtPrice” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(209,25,209,33): error CS0103: 当前上下文中不存在名称“txtStock” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(210,25,210,39): error CS0103: 当前上下文中不存在名称“txtPutawayDate” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(214,25,214,37): error CS0103: 当前上下文中不存在名称“lblAddResult” 1>D:\vs\GoodsWebService\GoodsWebClient_DirectDB\Default.aspx.cs(221,13,221,25): error CS0103: 当前上下文中不存在名称“lblAddResult”
01-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值