将网站转换为Web应用程序
1.新建web应用程序,清除应用程序中默认生成的文件
2.将网站中的文件复制到web应用程序中
3.将网站的App_Code文件重命名
4.右键web应用程序,点击将转换为应用程序项目
5.添加引用
6.添加命名空间
搜索并添加名字空间
static ArrayList ReplaceClassFile(DirectoryInfo dir)//搜索文件夹中的文件
{
ArrayList FileList = new ArrayList(); FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
FileList.Add(fi.FullName);
//Console.WriteLine(fi.FullName); //class namespace 檢測是否包含namespace 不包含則添加namespace
string filecontent = ReadFile(fi.FullName);
if (filecontent.IndexOf("namespace") < && fi.Extension==".cs")
{
int classindex = filecontent.IndexOf("public class");
if (classindex < ) classindex = ;
filecontent = filecontent.Insert(classindex, "\r\nnamespace xxx\r\n{\r\n");
int lastindex=filecontent.LastIndexOf("}");
filecontent=filecontent.Insert(lastindex, "\r\n }\r\n ");
Console.WriteLine("不存在namespace" + fi.FullName + "\n\t" ); if (WriteFile(fi.FullName, filecontent))
{
Console.WriteLine("新增namespace成功");
} }
} DirectoryInfo[] allDir = dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
ReplaceClassFile(d);
}
return FileList;
} static ArrayList ReplaceAspxPage(DirectoryInfo dir,string namespaceString)//搜索文件夹中的文件
{
ArrayList FileList = new ArrayList(); FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
FileList.Add(fi.FullName);
//Console.WriteLine(fi.FullName); //class namespace 檢測是否包含namespace 不包含則添加namespace if (fi.Extension == ".cs" && (fi.Name.IndexOf("aspx.cs") > || fi.Name.IndexOf("designer.cs") > ))
{
string filecontent = ReadFile(fi.FullName);
if (filecontent.IndexOf("namespace") < )
{
int classindex = filecontent.IndexOf("public partial class");
if (classindex < ) classindex = ;
filecontent = filecontent.Insert(classindex, "\r\nnamespace " + namespaceString + "\r\n{\r\n");
int lastindex = filecontent.LastIndexOf("}");
filecontent = filecontent.Insert(lastindex, "\r\n }\r\n ");
Console.WriteLine("不存在namespace" + fi.FullName + "\n\t"); if (WriteFile(fi.FullName, filecontent))
{
Console.WriteLine("新增namespace成功");
}
}
} if (fi.Extension == ".aspx")
{
string filecontent = ReadFile(fi.FullName);
if (filecontent.IndexOf("Inherits=\"xxx") < )
{ filecontent = filecontent.Replace("Inherits=\"", "Inherits=\"" + namespaceString + "."); Console.WriteLine("不存在namespace" + fi.FullName + "\n\t"); if (WriteFile(fi.FullName, filecontent))
{
Console.WriteLine("新增namespace成功");
}
}
}
} DirectoryInfo[] allDir = dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
ReplaceAspxPage(d, namespaceString);
}
return FileList;
}
将网站转换为Web应用程序的更多相关文章
- VS2013,asp.net网站转换为web应用程序
此功能已经不在右键菜单里了,而在主菜单中的“项目-->转换为WEB应用程序”
- 网站和Web应用程序的区别
新建项目里面的(ASP.NET Web 应用程序)主要是做B/S系统的,与winform的开发方式类似.新建网站(ASP.NET 网站)是主要开发网站的.其实你只要跟着教程做就行了.具体区别如下(借鉴 ...
- WEB服务器4--IIS中网站、Web应用程序和虚拟目录
网站.Web应用程序和虚拟目录 在IIS中可以创建网站.Web 应用程序和虚拟目录,以便与计算机网络上的用户共享信息. “网站”.“Web 应用程序”和“虚拟目录”这三个概念的关系如图 8‑1所示. ...
- [ASP.NET]Web网站与Web应用程序区别
[ASP.NET]Web网站与Web应用程序区别 本文链接:https://blog.csdn.net/a954553391/article/details/86403521 前言:在项目开发中, ...
- Web网站与Web应用程序区别
创建时的目录结构不同. WEB应用程序一般处理程序有命名空间,而网站中的没有.(因为应用程序最后要编译成一个DLL文件,会产生命名冲突,而网站每个页面会编译成每一个的DLL,不会文件内产生全名冲突). ...
- 菜鸟疑问之新建网站与新建web应用程序区别
学习asp.net一定少不了这困惑:新建网站与新建web应用程序有什么区别? 新建web应用程序 新建网站 呵呵,其实从名字看一个是webApplication,一个是webSite.名字不同罢了? ...
- 新建网站与新建Asp.Net Web 应用程序的区别
.net网站和应用程序区别,网站是动态执行的不用编译,他只依赖于自己的文档本身,甚至你用aspx里直接写jsp代码都可以,其实网站可以说只是在.net平台中打开的文档,相当于最初的记事本编码,他并不需 ...
- VS 2010 WebSite网站 使用CodeBehide 方式开发[Web应用程序项目转Web网站]
由于生成Web应用程序的文件非常大,100M左右,上传到香港太慢,对于运维工作很不现实, 所以只能改用单个源代码文件上传方式,也就是Web网站方式,但VS2010中只提供Web网站转Web应用程序功能 ...
- VS2010新建Web网站与新建Web应用程序的区别
在Visual Studio 2010中,除了可以使用“创建Web应用程序”的方式来构建自己的Web项目之外,还可以通过创建“Web网站”的方式来构建Web项其中,Web网站的创建方法:打开Visua ...
随机推荐
- 计算几何-Graham法-凸包
This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 关键一句话 Cr ...
- webstorm运行npm run dev慢
打开cmd窗口输入: npm config set registry https://registry.npm.taobao.org 再输入npm run dev就变快了
- 特征值 特征向量 正交分解 PCA
无意间想到的,有时间会补充内容. 还记得学线性代数时计算矩阵的特征值和特征向量,然后这个矩阵就可以用这个特征值和特征向量表示. 这样就可以理解成矩阵其实是多个向量拼在一起的,这样就可以将矩阵和向量建立 ...
- java读/写文件
读取文件参考:https://blog.csdn.net/weixin_42129373/article/details/82154471 写入文件参考:https://blog.csdn.net/B ...
- matplotlib添加坐标轴实现性格测试可视化
一张图展示最终效果 皮一下很开心,标签名肯定不是用户想要的,所以在这里尝试了定制化功能 功能&方法: 定制化标签名/标签数量(4个/5个).实现方法:在第一个界面点击cancel按钮,进入修改 ...
- redis集群(Sentinel)
问题 Redis 主哨兵模式是如何保证高可用的 主要依赖主哨兵的发现故障和故障转移 概述 本文假设读者对redis 的主从复制已经进行了了解 . Redis 主哨兵集群为Redis 提供了高可用,即高 ...
- Java switch的用法
控制流程语句之→switch选择判断语句 注意事项: 1.多个case后面的值不能重复: 2.switch后面小括号当中只能是下列数据类型: 基本数据类型:byte.short.char.int 引 ...
- Linux双网卡bond、起子接口
适用场景 服务器两张网卡需要做bond,并且bond后网卡需配置不同网段的地址,用于走不同流量,这个时候就可以采用起子接口的方式. 实验场景 设备 服务器:Server_A 核心交换机:Switch_ ...
- Spring中如何使用工厂模式实现程序解耦?
目录 1. 啥是耦合.解耦? 2. jdbc程序进行解耦 3.传统dao.service.controller的程序耦合性 4.使用工厂模式实现解耦 5.工厂模式改进 6.结语 @ 1. 啥是耦合.解 ...
- springboot去除内嵌tomcat和打包在tomcat中运行需要做的步骤
去除内嵌tomcat和添加jsp依赖 去除内嵌tomcat 在springboot启动依赖中去除内嵌tomcat <dependency> <groupId>org.sprin ...