Publish Web Site + reverse engineer and get back .aspx? - c#

Actually those 2 links talks about the .net Reflector. But my problem is that when we choose the PUBLISH WEBSITE option for a WebSite in Visual Studio, and then in the next window that comes up, uncheck all the 3 options which are
Allow this precompiled site to be updatable --> Not Checked
Use fixed naming and singe page assemblies -->Not Checked.
Enable strong naming on pre-compiled assemblies --> Not Checked.
In the location where the files are placed , we can see .aspx file which has the content This is a marker file generated by the precompilation tool, and should not be deleted!.
Now in the current scenario that I can facing, some person has published the website , using the PUBLISH WEB SITE option and then deleted the existing dotnet code. Now if I reverse engineer using the .Net Reflector, I get back .aspx.cs files, but I cannot get back the .aspx files.. Actually the .aspx file contents are represented as a class which inherits from the Page Class of dotnet. Below is the sample snippet what I get from the reflector
public class HomePage : Page, IRequiresSessionState
{
// Fields
protected HtmlForm Form1;
protected Literal InvalidPortalHeader;
protected Literal InvalidPortalText;
protected Table Table1;
.................. Something like this.
If code is generated in this format, then I will have to add new controls to the webpage in this format. Is there a way that I can get back the .aspx file also (not only the .aspx.cs file), so that I can add new controls like Label, Textbox at design time using my Visual Studio.
Is there any idea to get that .aspx file with original code?

Related

In VS 2019 - How to regenerate code-behind and designer files from an existing aspx page

I imported in my project Web c# an aspx page, for example, mypage.aspx, with HTML code. This page is very simple.
All I want is to generate the 2 files (in IDE) aspx.cs and designer.cs (mypage.aspx.cs and mypage.aspx.designer.cs).
I tried "Convert to web project" functionality but it does not work.
Any idea, please?
Of course, I read several solutions on this site but none worked (with vs 2019).
If there is no actual code in the original code-behind file then it's pretty easy to do. Create a new page of the same name. Then just copy and paste the markup from the original, taking care to leave the newly-created page directive as is.
If there was logic in your original code-behind then you're out of luck. You might try decompiling the original DLL and try to re-create the original code that way.

VSIX extension that creates a .cs file in the current project when a button is pressed

In short, im creating a Visual Studio extension in c# that enables non-automation testers to create automation scripts for web based solutions (using selenium).
We've created a template already for users that lays out the project file structure (test runners etc) and im using windows forms toolbox controls to create the dialogue windows where they will enter things like URls, Xpaths, page names etc etc
My question is this;
How on earth do i go about creating .CS files dynamically based on their inputs in these toolbox windows?
The simplest (he says) window i have is one that simply allows them to enter a URl and a webpage name. When they click the 'ok' button on this window, it should create a new .CS file with the webpage name as the class name, the url as a string that the webdriver can use to kick off the test and a few other bits and pieces as a template for them to start adding web elements to.
Any guidance would be greatly appreciated, there seems to be precious little around the web about creating VS extensions!
You got a few options here.
Typically, most people would do this by implementing a custom project item template, along with a custom IWizard based wizard associated with your template.
If you are displaying a modal UI from your IWizard.RunStarted, you can simply populate the ReplacementsDictionary with the text gleaned from your custom UI, which would then be swapped for the tokens in your templatized .cs file.
Or you could programmatically add code to the file after it was generated and added to the project (admittedly a much uglier and more difficult to code).
And finally, you could just generate the file in the project directory, and programmatically add it after the fact.
There's a number of old blog articles from the archived VSX Arcana blog that you might also find helpful.

The relationship between code behind class and aspx generated class

I was reading a book says that "a Web Form’s code-behind class was the base class for the class generated by the runtime from the .aspx file itself, as the picture below shows:
I don't know how the generated class looks like, as I only deal with aspx.cs which is the code-behind class.
So let say I have a .aspx file that have some controls like textboxes, do the generated class generated by .aspx file contains Textbox class? and how this generated class inherit the code-behind class, I'm really confused, can anybody post an example code of generated class generated by .aspx file?
The generated classes are stored here:
%windir%\Microsoft.NET\Framework\version\Temporary ASP.NET Files\root
Replace the version in the above path with the version of your framework. There will be many files in there but you can delete them all to start afresh. Then restart the web application in question and you will see a brand new folder (with a numeric name) will be created in the root folder. Inside the folder you will see many files but if you sort them by type, one of the CS Files will be the one generated for the .aspx page. The name will not be a friendly name so you will have to keep opening them and search for nameofpage_aspx. For example, if the aspx page is named About, search for about_aspx. If you do not find it, search for it in another file and one of them will be for about_aspx.
You may also look for the first line in the file which starts with #pragma checksum and it will have the name of the .aspx page. Not all files will have this line.
In those CS File types are the generated code which will be used by asp.net and you can examine its contents in more details if you want. Please do not ask me to explain the details of what is in those files but I am sure if you search online, you will find info on that.

Content of webpage doesn't display in Module in DotnetNuke

I am new in DotnetNuke. So, first of all I don't know all terminology. My problem is content of Webform.aspx doesn't display in Module.
Let me describe the steps so it can be easy to track the missing steps if any.
1- Created a project of DotnetNuke 7 C# Compiled Module. Path:
F:\website\dnndev.me\desktopmodules\DNNModule2
2- Added a WebForm1.aspx and add a line "Hello World"
3- Build project, DNNModule2_00.00.01_Install.zip is generated in
F:\websites\dnndev.me\DesktopModules\DNNModule2\DNNModule2\install
4- Added extension in http://www.dnndev.me/Admin/Extensions. It added
successfully in Modules.
5- Created New Page and added DNNModule2 by drag and drop. But it
doesn't display content "Hello World" of WebForm1.aspx.
Do I need to set any property while I am adding Module in New WebPage?
Also suggest if my flow is wrong. I will be happy to improve.
Thanks
For a DNN module to work properly you need to work with an .ascx user control. Typically these will inherit from the PortalModuleBase class. There are a few options, but that is the most common.
.aspx pages themselves can exist in DNN, however, they are ONLY available if you access them directly, and not through the module process.
Your user control, when setup should be part of the .dnn manifest and referenced with a <controlkey/> value. (As in no control key defined, to be the default view of your module.)
If you are not using a template, this one is a great example.

Loading html page from a template on the computer

I am working with a C# on visual studios.
What I would like to know is if it is possible to have a html template loaded from a directory on my computer. Then every time I load up my code it will load up the .html template automatically.
Yes there is a way, not suggested but exist. You can use this code to include the file, inside your asp.net page.
<!--#include file="template.htm"-->
What is dose is that is load this htm file and show it on the place that you have place this declaration. Also you must know that this file can not contain anything dynamically. This is a command code that comes from the old asp script code, and still work on asp.net
So I can not call it as template. If you wish to make something like a real template you must use a master page. Using a master page is far better, and you just copy paste your htm code inside the master page and there you have it.
relative: http://triaslama.wordpress.com/2008/11/19/how-to-include-file-in-aspnet-pages/

Categories

Resources