Skillfully use VS2005 to solve the problem of VS2005 website publishing inconvenience

Source: Internet
Author: User
Tags inheritance net
Solve the problem

  First, the introduction of problems

In the VS2005 website development process, the website release question has been a problem. The Web site created by VS2005 has several default directories: App_code,app_data,app_themes ...

If it is but cs/vb files, such as the UploadFile.cs class UploadFile, this class file does not have a visual aspx file, then the file must be placed in the App_Code directory, otherwise the class is inaccessible in the VS2005 Web site. Then put it in. But at compile time (my VS2005 is the team version, generate no response, feel like checking the code, can only use the publishing site to precompile.) I don't know what the other versions are. Here's the problem. When you choose to publish your Web site, it lets you choose how you want to publish it, and the General option defaults to it. The number of DLLs generated is less. After release, there will generally be app_code.compiled,app_code.dll,app_web_ in the bin directory (random character). dll, referenced DLL, and so on. The problem is here, if you want to do a virtual-free program, it is possible that the bin directory will need to put two app_code.dll? Wouldn't it be a conflict? Also, if the program changes once and needs to be republished, it's over. Let's see what VS2005 did. Inherits= "Mycodegif, App_web_vf3ukhnv" was good, A mycodegif.aspx file, a MyCodeGif.aspx.cs file, now mycodegif.aspx file inherits from Mycodegif, APP_WEB_VF3UKHNV, You can see that mycodegif is a MyCodeGif.aspx.cs-defined class, APP_WEB_VF3UKHNV is a DLL file name in the Bin folder. You try to publish again, more headaches problem comes, how mycodegif.aspx page and inherit from Mycodegif, App_web_qwdwqd? The compiled assembly name is different!

  Second, ASP. The relationship between pages and classes in net

In asp.net, pages can be inherited from classes and can be inherited multiple. such as mycodegif.aspx paging file

<%@ Page language= "C #" autoeventwireup= "true" codefile= "MyCodeGif.aspx.cs" inherits= "Mycodegif"%> This is the MyCodeGif.aspx.cs.
Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using Freecodenum;
public partial class MyCodeGif:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
//..... Logic
}
}

Visible mycodegif.aspx page inheritance from class Mycodegif can also be inherited, mycodegif.aspx paging file

<%@ Page language= "C #" autoeventwireup= "true" codefile= "MyCodeGif.aspx.cs" inherits= "Mycodegif"%>

This is the MyCodeGif.aspx.cs.

Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using Freecodenum;
public partial class Mycodegif:pagebase
{
protected void Page_Load (object sender, EventArgs e)
{
//..... Logic
}
}

PageBase.cs this

Using System;
Using System.Web;
Using System.Collections;
/**////<summary>
Summary description of Pagebase
</summary>
public class PageBase:System.Web.UI.Page
{
Public Pagebase ()
{
}
}

As if I mycodegif.aspx the paging file, I can even

<%@ Page language= "C #" autoeventwireup= "true" codefile= "MyCodeGif.aspx.cs" inherits= "Pagebase"%> That is, the page inherits directly from the Pagebase class.

  Third, the solution

You can also customize the name of the assembly in VS2005-when you create the project, not the site. That is, you can create a Web site already written, you can re-create the project, and then the site's code to recompile. After the cheap, you may need to change the inheritance of the ASPX file, you may not have to change it, see how cheap you are, because the ASPX file inheritance and the class name (when there is a namespace, also specify the namespace). mycodegif.aspx paging file can be completely changed to

<%@ Page language= "C #" autoeventwireup= "true" inherits= "Pagebase"%>

Remove the codefile= "MyCodeGif.aspx.cs" inside.

This will be able to imitate the VS2003 way to publish the site. The process may be complex, but for later maintenance I feel very useful, after all, accustomed to the VS2003. and can and 20,031 like to do without the virtual program.

Complete the full text. Hope to be useful to everyone. Author: Cheping, sunset Track







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.