ASP.NET 웹 사이트를 ASP.NET 웹 응용 프로그램으로 변환하는 방법
ASP.NET 3.5 웹 사이트 (비주얼 스튜디오 용어)가 있지만 사이트는 계속 성장하고 있으며 다른 것들 중에서도 카우보이처럼 보입니다. 이것이 웹 응용 프로그램 (네임 스페이스 및 모두)으로 변환되는 것을보고 싶습니다.
Visual Studio에서 쉽게 수행 할 수있는 작업입니까? 그렇지 않다면 모든 네임 스페이스 등을 자동으로 생성 할 수있는 다른 도구가 있습니까?
"웹 사이트"에 "웹 응용 프로그램으로 변환"옵션이 존재하지 않는 것으로 나타났습니다. "웹 응용 프로그램으로 변환"옵션은 "웹 응용 프로그램"에만 존재합니다 !!!!
[내 강조]
따라서 여기에 거래가 있습니다. 변환을 수행하려면 다음을 수행해야합니다.
VS 2008 솔루션에 새 "웹 응용 프로그램"을 추가합니다 (파일-> 추가-> 새 프로젝트-> C #-> 웹-> ASP.NET 웹 응용 프로그램).
그런 다음 이전 "웹 사이트"의 모든 파일을 새로 만든 "웹 응용 프로그램"에 복사하고 기본적으로 생성 된 모든 파일을 재정의합니다.
다음 단계는 가장 추악합니다. "웹 사이트"의 참조를 새 "웹 응용 프로그램"에 "수동으로"추가해야합니다. VS 2008 PowerCommands 장난감이 다른 프로젝트 유형의 참조를 복사하기 때문에이 작업을 수행 할 것이라고 생각했지만 그렇지 않았습니다. 직접 수동으로 수행해야하며 동일한 어셈블리 (제 경우에는 AJAXToolkit과 같은)의 여러 버전이 있거나 GAC 및 로컬 버전이 둘 다있는 어셈블리가있는 경우이 단계에서주의해야합니다.
마지막 단계를 계속 반복하고 "웹 애플리케이션"을 빌드하십시오. " '....'is unknown namespace. You are missing an assembly reference?"와 같은 오류가 계속 발생합니다. '....'가 사용하는 서버 컨트롤의 ID로 대체 된 것 외에는 아무것도 없는지 확인하십시오. 즉, .DESIGNER.CS 또는 .DESIGNER.VB 파일 누락으로 인해 존재하는 오류 만 발생할 때까지 참조를 추가하고 프로젝트를 빌드하십시오.
그런 다음 VS 2008 솔루션 탐색기의 "웹 응용 프로그램"루트 프로젝트 노드로 이동하여 마우스 오른쪽 단추로 클릭하면 "웹 응용 프로그램으로 변환"옵션을 찾을 수 있습니다. 이 옵션이하는 일은 실제로 페이지 및 컨트롤의 "@Page"및 "@Control"지시문을 약간 변경하고 필요한 .DESIGNER.CS 또는 .DESIGNER.VB 파일을 만드는 것입니다.
"웹 응용 프로그램"을 다시 빌드하십시오. 오류가 발생하면 누락 된 참조를 확인하거나 "웹 응용 프로그램으로 변환"을 다시 클릭하십시오. 때로는 누락 된 DESIGNER 파일로 인한 오류 이외의 오류가있는 경우 모든 페이지 / 컨트롤에 해당 DESIGNER 파일이 생성되지는 않습니다. 비 DESIGNER 문제를 수정하고 "웹 응용 프로그램으로 변환"을 다시 클릭하면이 작업을 수행해야합니다.
성공적인 VS 빌드가 완료되면 준비가 된 것입니다. 웹 애플리케이션 테스트를 시작하십시오. 선택적으로 VS 2008 솔루션 탐색기에서 "웹 응용 프로그램"루트 프로젝트 노드를 마우스 오른쪽 단추로 클릭하고 "속성"을 클릭 한 다음 "웹"탭으로 이동하여 "웹 응용 프로그램"을 IIS의 가상 폴더로 설정할 수 있습니다 (새로 만들 수 있습니다. VS의 가상 디렉터리). 이전 "웹 사이트"에서 사용한 IIS 가상 디렉터리를 사용하려면 먼저 IIS에서 해당 가상 디렉터리를 제거해야합니다.
업데이트 : 페이지를 테스트 할 때 "App_Code"폴더에있는 클래스, 특히 네임 스페이스가없는 클래스에 가장주의를 기울이십시오. 큰 함정이 될 수 있습니다. 네임 스페이스가없는 동일한 정적 클래스에서 두 개의 확장 메서드 오버로드에 문제가있었습니다. 하나는 DateTime을 확장합니까? (Nullable) DateTime 자체를 확장하는 다른 오버로드를 호출합니다. 확장 메서드로 다른 오버로드를 호출하면 VS 2008 컴파일이 통과되고 런타임에서만 컴파일 오류가 발생했습니다 (IIS 사용). 다른 오버로드에 대한 호출을 확장 메서드로 호출하는 것에서 일반 정적 메서드로 호출하는 것으로 변경하면 (동일한 클래스의 호출 만 변경하고 다른 클래스의 호출은 확장 메서드 호출로 남아 있음)이 문제를 해결했지만 분명히 그렇지는 않습니다. VS 2005에서와 같이 안전합니다. 특히 네임 스페이스가없는 클래스에서.
Update2 : 변환하는 동안 VS 2008은 "App_Code"의 이름을 "Old_App_Code"로 바꿉니다. 이 새 이름은보기 흉하게 들리지만 다시 이름을 바꾸지 마십시오. "웹 애플리케이션"모델에서 모든 코드는 하나의 어셈블리에 있습니다. 런타임에서 웹 서버는 사용중인 웹 프로젝트 유형을 알지 못합니다. "App_Code"폴더의 모든 코드를 가져 와서 새 어셈블리를 만듭니다. 이렇게하면 "App_Code"라는 폴더에 코드가있는 경우 동일한 유형이 VS에 의해 생성 된 어셈블리와 IIS / ASP.NET Development Server에 의해 생성 된 두 어셈블리에 동일한 유형이 존재한다는 RUNTIME 컴파일 오류가 발생합니다. . 그것을 피하기 위해. "Old_App_Code"를 같은 이름으로 두거나 이름을 ANYTHING EXCEPT : "App_Code"로 변경합니다. 이러한 "App_Code"에 코드를 넣지 마십시오.
나는 이전부터 이것을 알고 있지만 "웹 사이트"모델을 오랫동안 사용하지 않았기 때문에 지금은 잊어 버렸습니다.
연습 : MSDN의 Visual Studio 에서 웹 사이트 프로젝트를 웹 응용 프로그램 프로젝트로 변환
웹 사이트 애플리케이션이 커지면 .. 여러 프로젝트로 분할하는 것이 좋습니다. 웹 사이트 프로젝트에서 웹 응용 프로그램 프로젝트로의 변환은별로 도움이되지 않습니다.
새 웹 응용 프로그램 프로젝트를 빌드하는 데 문제가있는 경우 모든 '도우미'클래스의 Visual Studio에서 파일 속성을 확인하세요. 프로젝트의 경우 Build Action을 Content로 설정했지만 Compile이어야했습니다.
Create a New Web Application in VS 2010.
1. Using Windows Explorer copy all your files into you project folder.
2. In VS 2010 solution explorer show all files.
3. Select the files and folders - right click include in project.
4. Right click the project solution explorer and select Convert to Web Application.
There are quite a few small differences, such as the App_Code folder will get renamed to old_app_code - that surprisingly doesn't cause any errors. The TypeName on your object data sources and the inherits on the @Page tag might need the [ProjectName]. prefix appended globally. For example if your type name was "BusinessLogic.OrderManager" and your project name is InventorySystem you would need to change it to InventorySystem.BusinessLogic.OrderManager. Also a few display changes, such as required field validators don't default to red font anymore, they default to black.
I was facing the same problems initially. After following the Wrox Professional ASP.NET 4.0 book, I found the following solution for my case.
I first created a new web application. Copied all the website files into the web application folder. Right click on the application, and click conver to web application.
You might ask why you need to convert a web app into a web app. The answer is, that when you create a website, you simply code the .cs file where-ever required. A web application, however declares .design.cs (or .vb) and a .cs file for the code and design section automatically.
NEXT: Remove all manual references, like 'Inherits' attribute in the PAGE directive, to other files in your website, since name spaces WILL take care of referencing the classes centrally.
I also faced a problem, since I had not included OBJ and BIN folder in my project. If you think you are missing your BIN and OBJ folders, simply click the 'Show All Files' icon in the Solution Explorer and then right click on the missing folders and add to project. (to make sure they compile with the project.)
UPDATE: As @deadlychambers points out in the comments: You can search everywhere by doing a "Ctrl + Shift + F" and then search for Inherits="(.*?)"
. This will find all occurrences and probably save you some time!
I've now successfully migrated one Website project to a web application and there is quiet a few gotchas to look out for.
Having ReSharper at your disposal helps a lot in refactoring the aspx files.
- Set up your solution and create an empty WebApplication
- Copy all file over
- aspx files in website projects don't have a namspace. Wrap your classes in the appropriate namespaces
- During copying, all my pages in subfolders got renamed to my project name and the foldername, so I got 40ish
public partial class FolderName_Projectname : Page
If neccessary rename all files using Resharper or manually. If you encounter multiple errors like"There is already a member Page_Load() defined"
, this is most likely due to incorrect class names und duplication - After adding a namespace
Replace
CodeFile
in all aspx pages withCodebehind
and especially pay attention to files i your subfolder. Make sureInhertis=""
doesn't contain the relative path. Your namespaces take care of everything. So the correct format isInherits="Namespace.classname"
. If your class has a namespace NaSpa and a filename foo.cs it would beInherits="NaSpa.foo"
After you have prepared all your files (don't forget your master pages), run "Convert to web application". If you encounter errors afterwards, rinse and repeat. If you encounter errors of the sort "TextBoxName can't be found are you missing a reference", make sure you did not forget to sanitize your aspx pages. A good indicator is to check the automatically generated designer files. If
TextBoxName
does not appear in there, the conversion did not succeed completely.- Resolve any missing dependencies.
- Build
the default ASP name space does not seem to work anymore. So I cannot seem to call my User Controls.ascx pages from outside the page. Giving them a namespace and changing the default from ASP to my namespace seemed to work.
참고URL : https://stackoverflow.com/questions/735054/how-to-convert-asp-net-website-to-asp-net-web-application
'code' 카테고리의 다른 글
PHP 경고 : PHP 시작 : 동적 라이브러리를로드 할 수 없습니다. (0) | 2020.09.22 |
---|---|
Docker, 그것은 무엇이며 목적은 무엇입니까 (0) | 2020.09.22 |
텍스트 그리기 (0) | 2020.09.22 |
URL의 조각 식별자에 유효한 문자 목록? (0) | 2020.09.22 |
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@xyz.com [closed] (0) | 2020.09.21 |