且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Visual Studio中将Web应用程序转换为Web站点?

更新时间:2023-08-20 17:42:34

参考 - 将ASP.NET Web应用程序转换为ASP.NET WebSite [ ^ ]

Refer - Convert ASP.NET Web Application to ASP.NET WebSite[^]
引用:

好的 - 假设你有备份,这就是我的意思解决它:



删除csproj文件

从Windows资源管理器中删除任何 designer.cs 文件

仍然在资源管理器中,在网站的根目录创建一个App_Code文件夹

查找任何 *。cs 不是代码隐藏的文件(例如, .ascx.cs .aspx.cs )并将它们移动到App_Code文件夹中

在Visual Studio中作为网站项目打开

验证.NET FX版本

更改 CodeBehind = CodeFile = 在任何 .aspx .ascx 文件

读取任何第三方参考资料

全球范围内存在一些潜在的复杂情况.asax,ASHX处理程序(需要内联)和引用页面和控件。你不得不手动处理这些 - 我担心 - 但如果这是一个小小的努力,它应该很容易实现。

Ok - assuming you have a backup, this is how I would tackle it:

Delete the csproj file
From within Windows Explorer, delete any designer.cs files
Still in Explorer, create an App_Code folder at the root of the site
Find any *.cs files that aren't code behinds (eg., .ascx.cs or .aspx.cs) and move them into the App_Code folder
Open in Visual Studio as Web Site project
Verify .NET FX version
Change CodeBehind= to CodeFile= in any .aspx or .ascx files
Readd any 3rd party references
There's some potential complications around Global.asax, ASHX handlers (need to be inline) and referencing pages and controls. You'll have to deal with those manually, I'm afraid - but if it's a smallish effort, it should be easily doable.