标签:
上一篇说到重写IHttpHandler实现前后端分离,这次说一下如何建立一个如下文件结构。
VS建立webform时是根据模板来的。C#的模板目录如下:
F:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSharp
WebForm的模板目录如下:
F:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSharp\Web\Web Forms\2052\WebForm
里面有几个文件
打开原WebForm.vstemplate可以看到以下代码:
1 <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item"> 2 <TemplateData> 3 <Name Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="3062"/> 4 <Description Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="3063"/> 5 <Icon Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="4533"/> 6 <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp> 7 <TemplateID>Microsoft.WAP.CSharp.WebForm</TemplateID> 8 <TemplateGroupID>Web</TemplateGroupID> 9 <ProjectType>CSharp</ProjectType> 10 <ProjectSubType>Web</ProjectSubType> 11 <ShowByDefault>false</ShowByDefault> 12 <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion> 13 <DefaultName>WebForm.aspx</DefaultName> 14 <SortOrder>20</SortOrder> 15 </TemplateData> 16 <TemplateContent> 17 <References> 18 <Reference> 19 <Assembly>System.Web</Assembly> 20 </Reference> 21 <Reference> 22 <Assembly>System</Assembly> 23 </Reference> 24 <Reference> 25 <Assembly>System.Data</Assembly> 26 </Reference> 27 <Reference> 28 <Assembly>System.Drawing</Assembly> 29 </Reference> 30 <Reference> 31 <Assembly>System.Xml</Assembly> 32 </Reference> 33 </References> 34 <CustomParameters> 35 <CustomParameter Name="$ParentExtension$" Value=".aspx"/> 36 <CustomParameter Name="$ChildExtension$" Value=".cs"/> 37 </CustomParameters> 38 <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$">Default.aspx</ProjectItem> 39 <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$.cs" SubType="ASPXCodeBehind">Default.aspx.cs</ProjectItem> 40 <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$.designer.cs">Default.aspx.designer.cs</ProjectItem> 41 </TemplateContent> 42 <WizardExtension> 43 <Assembly>Microsoft.VisualStudio.Web.Application, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly> 44 <FullClassName>Microsoft.VisualStudio.Web.Application.WATemplateWizard</FullClassName> 45 </WizardExtension> 46 </VSTemplate>
想改成.html嵌套.cs,修改WebForm.vstemplate为:
1 <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item"> 2 <TemplateData> 3 <Name Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="3062"/> 4 <Description Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="3063"/> 5 <Icon Package="{39c9c826-8ef8-4079-8c95-428f5b1c323f}" ID="4533"/> 6 <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp> 7 <TemplateID>Microsoft.WAP.CSharp.WebForm</TemplateID> 8 <TemplateGroupID>Web</TemplateGroupID> 9 <ProjectType>CSharp</ProjectType> 10 <ProjectSubType>Web</ProjectSubType> 11 <ShowByDefault>false</ShowByDefault> 12 <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion> 13 <DefaultName>WebForm.html</DefaultName> 14 <SortOrder>20</SortOrder> 15 </TemplateData> 16 <TemplateContent> 17 <References> 18 <Reference> 19 <Assembly>System.Web</Assembly> 20 </Reference> 21 <Reference> 22 <Assembly>System</Assembly> 23 </Reference> 24 <Reference> 25 <Assembly>System.Data</Assembly> 26 </Reference> 27 <Reference> 28 <Assembly>System.Drawing</Assembly> 29 </Reference> 30 <Reference> 31 <Assembly>System.Xml</Assembly> 32 </Reference> 33 </References> 34 <CustomParameters> 35 <CustomParameter Name="$ParentExtension$" Value=".html"/> 36 <CustomParameter Name="$ChildExtension$" Value=".cs"/> 37 </CustomParameters> 38 <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.html">Default.html</ProjectItem> 39 <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.cs" SubType="ASPXCodeBehind">Default.cs</ProjectItem> 40 41 </TemplateContent> 42 <WizardExtension> 43 <Assembly>Microsoft.VisualStudio.Web.Application, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly> 44 <FullClassName>Microsoft.VisualStudio.Web.Application.WATemplateWizard</FullClassName> 45 </WizardExtension> 46 </VSTemplate>
把里面模板里面关联文件修改如下:(.html和.cs文件可以更具公司平台做一标准页面出来。)
如果不是原生WebForm要用服务器控件Default.aspx.designer.cs ,可以删掉。
改好之后建个文件试试吧
标签:
原文地址:http://www.cnblogs.com/colorlife/p/4747267.html