将网站转换为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 ...
随机推荐
- 虚拟函数是否应该被声明仅为private/protected?
问题导入 我想对于大家来说,虚拟函数并不能算是个陌生的概念吧.至于怎么样使用它,大部分人都会告诉我:通过在子类中重写(override)基类中的虚拟函数,就可以达到OO中的一个重要特性——多态(pol ...
- SQL Server带列名导出到Excel(Export to CSV with headers)的几个思路
https://www.cnblogs.com/downmoon/archive/2012/05/04/2482995.html SQL Server 2008中SQL应用系列及BI学习笔记系列- ...
- easy-rules
我们在写业务代码经常遇到需要一大堆if/else,会导致代码可读性大大降低,有没有一种方法可以避免代码中出现大量的判断语句呢?答案是用规则引擎,但是传统的规则引擎都比较重,比如开源的Drools,不适 ...
- 吴裕雄 python 机器学习——局部线性嵌入LLE降维模型
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from sklearn import datas ...
- 题解【SP1043】 GSS1 - Can you answer these queries I
题目描述 You are given a sequence \(A_1, A_2, ..., A_n(|A_i|≤15007,1≤N≤50000)\). A query is defined as f ...
- Go第三方库之tail
Tail Demo // tail.TailFile()函数开启goroutine去读取文件,通过channel格式的t.lines传递内容. t, err := tail.TailFile(&quo ...
- 每天进步一点点------Verilog 测试平台(Testbench) (一)
每天进步一点点------Verilog 测试平台(Testbench) (一)
- java8下 枚举 通用方法
在项目中经常用到枚举作为数据字典值和描述的相互转化. 用法如下: public enum CommunicationParamsCom { COM_1(1, "COM1"), CO ...
- angular2 单元测试 路由相关
第一步:在html模板中,写路由链接,并保证有路由出口 第二步:写自定义的路由指令和路由出口组件,因为在单元测试中不需要引入真实的路由,此处我们用虚拟的代替即可. 第三步:将自定义的虚拟路由指令和路由 ...
- 如何在JDBC Connection Configuration配置组件上添加控件
如何在JDBC Connection Configuration配置组件上添加控件 最近项目刚上线,闲来无事又把Jmeter的源码拿出来研究研究,最初的目的是想扒一扒Jmeter里数据库处理的逻辑是怎 ...