开发者

How to place aspx-files in seperate Web Application Projects in one solution?

We have been building ASP.Net websites for many years. During this time we gathered a lot of knowledge of ASP.Net. We know what to use, a what not. One problem is still, persistently, bugging us. I hope to solve this for once and for all.

We have a fairly large solution with lots of aspx-files. All aspx-files reside in one Web Application Project. This single big WAP needs to be split in multiple smaller projects. The exact reasoning is beside the point, please believe me ;-).

There are a 开发者_运维问答number of ways to accomplish this, but I am still unsure what the best way would be. We use ASP.Net 4.0 and Visual Studio 2010 Premium.

Any advice is greatly appreciated.

This is our current work-around (which we do not like)

  1. Create a WAP (Runner).
  2. Create a second WAP (ProjectA)
  3. Create a third WAP (ProjectB)
  4. Delete the web.config's in ProjectA and ProjectB
  5. Create a simple aspx-file in Runner, ProjectA and ProjectB with a hello world message
  6. Remove ProjectA and ProjectB
  7. Go to Windows Explorer
  8. Move the folders ProjectA and ProjectB inside the folder Runner
  9. Go back to Visual Studio
  10. Add Existing Project to solution (ProjectA and ProjectB)
  11. Hit F5
  12. Navigate to http://localhost:4867/WebForm1.aspx
  13. Navigate to http://localhost:4867/ProjectA/WebForm1.aspx
  14. Navigate to http://localhost:4867/ProjectB/WebForm1.aspx

Tada! The above works, but it feels like a hack and it smells awful. Is there a better way?


Here is what Scott Guthrie says on this. I think the second method is a superset of your procedure. In my opinion you are right: This is a hack - but the official one.


I suggest creating a new solution, and creating your required new empty web application projects under it. Then, manually copy your files from their original locations into the proper new folders which were created when you created the empty projects. After all the files are in place, go back to VS. Set Solution Explorer to 'Show All Files'. Select the the files you need in each project, right click, and select 'Include in Project'.

The only wrinkle I can think of is that creating all web applications will mean you have a web.config file in each. If this is what you need, then fine. Otherwise, you create some of the projects as class libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜