Creating sub-projects in IIS with Web Application Projects

 

Part 1 of 3: Creating sub-projects in IIS with Web Application Projects

From: http://blogs.msdn.com/webdevtools/archive/2006/07/01/652986.aspx
 

This post is one of a three part series that describes how to factor development of a single large ASP.NET application into multiple projects inside of Visual Studio 2005 using the Web Application Projects add-in.

Part 1 of 3: In this post, I’ll describe the basics on how to setup a sub-project structure using IIS.

     Part 2 of 3: Creating shared user controls and master pages with sub-projects

Part 2 of 3: The next post will describe intricacies with master pages, user controls, and project references when using a sub-project structure.

    • Creating a shared master page in the root project and using it in sub-projects
    • Creating a shared user control in the root project and using it sub-projects

Part 3 of 3: The final part to the series will describe how to use the same technique but with the built-in development server in Visual Studio 2005.

Part 3 of 3: Creating sub-projects using the Visual Studio Development Server and Web Application Projects

Why use sub-projects?

With very large web applications, such as those that contain thousands of files, using a sub-project structure in Visual Studio provides several benefits.

At development time, it provides a clean isolation between different parts of the application. This enables different developers to own their own projects within a single web application, and allows them to make changes without affecting code that is in a different project.

As well, using sub-projects provides a clean way to compartmentalize functionality so different parts of the application can be developed in isolation from others. The compartmentalization also enables the ability to deploy the various sub-projects to production independently from each other thus providing more flexibility around incremental updates to one part of the application without affecting other parts.

Setting up the root project using IIS

The first thing I want to show is a step-by-step on how to setup a sub-project project structure based on developing on IIS.

Setting up a sub-project structure in Visual Studio 2005 is fairly straightforward. If one has done it in Visual Studio 2003, the process described below should be very familiar.

Here is a step-by-step walkthrough of how to setup sub-projects using Visual Studio 2005 and the Web Application Projects add-in.

1) Download and install “Web Application Projects” add-in(For VS2005). The add-in can be installed from the following location: http://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx

2) Create the root project. The first thing we want to do is create a new Web Application project that will represent the root of the application in IIS. To do this select File > New Project. Choose the ASP.NET Web Application item, and type in a name and location for the root project. In this example we’ll call the root project MyLargeWebApp. Make sure the “Create directory for solution” checkbox is unchecked. One can create the “Root” project in a folder in the “inetpub/wwwroot” directory for IIS, or in any other location where you wish to create the virtual root for your app. In this example, we’ll use a location underneath “inetpub/wwwroot”.

3) The next step is to map the MyLargeWebApp project in IIS using the “Web” tab in project properties. To do this, right-click on the root node of the project and select “Properties”. Click the “Web” tab on the page that is launched, and select the “Use IIS Web Server” option.

4) Next you need to create a virtual directory mapping in IIS to point to the location where your root project exists. To do this click the “Create Virtual Directory” button on the same Properties page.

5) You can now test your root project, by adding some content to default.aspx and selecting F5. This should run launch IE and the default.aspx page will get served from IIS.

Creating sub-projects under a root project

Once the root project is up and running fine, the next step is to create a sub-project and set it up so it builds and runs as part of the same ASP.NET application represented by the root project. The following steps describe how to do this:

1) The first thing you need to do is add a new Web Application project to the same solution. Make sure the MyLargeWebApp solution/project is already open in the solution explorer. To add a new project to the solution, select “File > Add > New Project”. Select “ASP.NET Web Application” as the template. Then type in a name for the sub-project (“SubProject1” in this example), and set it to the location of the folder where the root project is (c:\inetpub\wwwroot\MyLargeWebApp in this example).

2) You should now have two projects in your solution which represent a single ASP.NET application. To verify this, go to the IIS management console by selecting Start > Run > inetmgr in Windows. In the management console, you should see a “SubProject1” folder under single IIS web application called “MyLargeWebApp”.

3) To get the sub project building and running a few more steps are required in Visual Studio. The first thing you should do is delete the web.config file in the sub-project.

4) Next you need to adjust a few of the properties for the sub-project. Right click on the sub-project’s node in solution explorer and select “Properties”. Under the “Compile” page change the “Build output path” to “..\bin\”.

5) Finally in the sub-project’s properties, under the “Web” page, select the “Use IIS Web Server” option and change the “Project URL” setting to “http://localhost/MyLargeWebApp/SubProject1”.  Also check the "Overwrite application root URL" and provide the URL to the root project, which in this case is "http://localhost/MyLargeWebApp/". Do not click the “Create Virtual Directory” button in the sub-project’s setting as you don’t want to create another application root in IIS at the sub-projects folder.

6) Once you’ve updated these properties for the sub-project, the sub-project should be ready to go. Add some content to the default.aspx page in the sub-project and press F5. This should build the sub-project, deploy its DLL to the \bin of the root project, and then run the page from the sub-project. If you select the root-project and “Show All Files” in the solution explorer, you will see in its \bin folder that there are two deployed assemblies, one for the root project (MyLargeWebApp.dll) and one for the sub-project (SubProject1.dll).

Summary

This wraps up my first post on sub-projects. Hopefully it provides a quick introduction on how to setup a sub-project structure using the Web Application Project add-in for Visual Studio 2005.

As mentioned in the beginning of the post, sub-projects are a good way to partition a single large ASP.NET application into several Visual Studio projects so you get the benefits of isolated development and deployment.

Looking forward to hear from you about this post, and I'll update with Part 2 hopefully next week.

--Omar

ASPNET_SubProjects_In_IIS_WebApplications_1

ASPNET_SubProjects_In_IIS_WebApplications_2

ASPNET_SubProjects_In_IIS_WebApplications_3

如何为asp.net网站项目添加子项目
 

我采取了重新建立一个projects的方法,比如把后台管理剥离出来,新建一个admin的website,这个新的projects放在website的根目录下,然后修改文件编译生成dll后的目录为..\bin并且删除项目中的web.config.编译后访问,呵呵,真的可以访问了,并且达到了拆分项目的要求.倒是并不完美,还有手动修改很多设置,并且这2个项目中不能共享相同的master,和usercontrol,甚至是图片,js等,如果直接使用相对路径,那么视图模式下将不能正常显示,如果vs直接提供新建子项目的功能并能解决共享这些文件,该有多好啊.
于是通过Google,找到一篇文章http://blogs.msdn.com/webdevtools/archive/2006/07/01/652986.aspx,Creating sub-projects in IIS with Web Application Projects,不幸的是文中提到的“Web Application Projects” add-in,我Download了,but can't install!
虽然这样的应用程序我们无法制作,但是我们可以按照他的思路自己修改配置啊.
发现他的方法,跟一开始我的做法是很类似的,不过他可以共享master和user control,为什么我的不能呢?
仔细翻看了一下,发现原来他在子项目中创建了虚拟目录比如 http://localhost/group,所以之前使用~/Group.Master,只能访问本项目中的master,而现在则可以访问根目录中的master了,试试usercontrol,也可以了,呵呵,原理奥妙都在这个虚拟目录中呀.
本文来自:http://www.jb51.net/article/16300.htm

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


引言 本文从Linux小白的视角, 在CentOS 7.x服务器上搭建一个Nginx-Powered AspNet Core Web准生产应用。 在开始之前,我们还是重温一下部署原理,正如你所常见的.Net Core 部署图: 在Linux上部署.Net Core App最好的方式是在Linux机器
引言: 多线程编程/异步编程非常复杂,有很多概念和工具需要去学习,贴心的.NET提供Task线程包装类和await/async异步编程语法糖简化了异步编程方式。 相信很多开发者都看到如下异步编程实践原则: 遵守以上冷冰冰的②③条的原则,可保证异步程序按照预期状态正常运作;我们在各大编程论坛常看到违背
一. 宏观概念 ASP.NET Core Middleware是在应用程序处理管道pipeline中用于处理请求和操作响应的组件。 每个组件是pipeline 中的一环。 自行决定是否将请求传递给下一个组件 在处理管道的下个组件执行之前和之后执行业务逻辑 二. 特性和行为 ASP.NET Core处
背景 在.Net和C#中运行异步代码相当简单,因为我们有时候需要取消正在进行的异步操作,通过本文,可以掌握 通过CancellationToken取消任务(包括non-cancellable任务)。 Task 表示无返回值的异步操作, 泛型版本Task<TResult>表示有返
HTTP基本认证 在HTTP中,HTTP基本认证(Basic Authentication)是一种允许网页浏览器或其他客户端程序以(用户名:口令) 请求资源的身份验证方式,不要求cookie,session identifier、login page等标记或载体。 - 所有浏览器据支持HTTP基本认
1.Linq 执行多列排序 OrderBy的意义是按照指定顺序排序,连续两次OrderBy,后面一个有可能会打乱前面一个的排序顺序,可能与预期不符。 要实现sql中的order by word,name类似效果; LINQ 有ThenBy可以紧接使用, ThenBy记住原本排序的值,然后再排其他值,
ASP.NET Core 核心特性:开源、跨平台、高性能是其决战JAVA的必胜法宝,最引人关注的跨平台特性 到底是怎么实现? 
 本文分Unix、Windows剖析跨平台内幕,读完让你大呼过瘾。
前导 Asynchronous programming Model(APM)异步编程模型以BeginMethod(...) 和 EndMethod(...)结对出现。 IAsyncResult BeginGetResponse(AsyncCallback callback, object state
引言 最近在公司开发了一个项目,项目部署架构图如下: 思路 如图中文本所述,公司大数据集群不允许直接访问外网,需要一个网关服务器代理请求,本处服务器A就是边缘代理服务器的作用。 通常技术人员最快捷的思路是在服务器A上部署IISʺpplication Request Routing Module组件
作为一枚后端程序狗,项目实践常遇到定时任务的工作,最容易想到的的思路就是利用Windows计划任务/wndows service程序/Crontab程序等主机方法在主机上部署定时任务程序/脚本。 但是很多时候,若使用的是共享主机或者受控主机,这些主机不允许你私自安装exe程序、Windows服务程序
引言 熟悉TPL Dataflow博文的朋友可能记得这是个单体程序,使用TPL Dataflow 处理工作流任务, 在使用Docker部署的过程中, 有一个问题一直无法回避: 在单体程序部署的瞬间(服务不可用)会有少量流量无法处理;更糟糕的情况下,迭代部署的这个版本有问题,上线后无法运作, 更多的流
合格的web后端程序员,除搬砖技能,还必须会给各种web服务器配置Https,本文结合ASP.NET Core部署模型聊一聊启用Https的方式。 温故知新 目前常见的Http请求明文传输,请求可能被篡改,访问的站点可能被伪造。 HTTPS是HTTP加上TLS/SSL协议构建的可进行加密传输、身份认
长话短说 前文《解剖HttpClientFactory,自由扩展HttpMessageHandler》主要讲如何为HttpClientFactory自定义HttpMessageHandler组件, 现在来完成课后的小作业: 将重点日志字段显示到Nlog的LayoutRenderer上。 本文实现一个
引言问题 作为资深老鸟,有事没事,出去面试;找准差距、定位价值。 面试必谈哈希, Q1:什么是哈希? Q2:哈希为什么快? Q3:你是怎么理解哈希算法利用空间换取时间的? Q4:你是怎么解决哈希冲突的? Q5:你有实际用写过哈希算法吗? 知识储备 哈希(也叫散列)是一种查找算法(可用于插入),哈希算
前言 如题,有感于博客园最近多次翻车,感觉像胡子眉毛一把抓, 定位不了生产环境的问题。 抛开流程问题,思考在生产环境中如何做故障排除, 发现博客园里面这方面的文章比较少。 .Net 本身是提供了sos.dll工具帮助我们在生产中故障排除,通过提供有关内部公共语言运行时(CLR)环境的信息,
.NET程序是基于.NET Framework、.NET Core、Mono、【.NET实现】开发和运行的 ,定义以上【.NET实现】的标准规范称为.NET Standard .NET Standard .NET标准是一组API集合,由上层三种【.NET实现】的Basic Class Library
长话短说 上个月公司上线了一个物联网数据科学项目,我主要负责前端接受物联网事件,并提供 参数下载。 webapp 部署在Azure云上,参数使用Azure SQL Server存储。 最近从灰度测试转向全量部署之后,日志时常收到: SQL Session超限报错。 排查 我在Azure上使用的是 S
临近年关,搜狗,360浏览器出现页面无法成功跳转,同域Cookie丢失? 也许是服务端 SameSite惹的祸。
本文揭示由于Chrome低版本内核不识别 SameSite= None, 引发的单点登录故障。
本文聊一聊TraceID的作用和一般组成,衍生出ASP. NETCore 单体和分布式程序中 TraceId 的使用方式
通过给 HttpClint请求的日志增加 TraceId,解锁自定义扩展 HttpClientFacroty 的姿势