Need to debug both asp and silverlight solutions together - asp.net

I have two solutions, one is asp.net and another one silverlight solution. Both of them are hosted on my local server. What I need is to debug two solutions simultaneously, in asp solution i have page with a code like that
<iframe src="http://localhost/UI_RegInc/UI_RegInc.aspx?UserId=<%=UserId%>"
frameborder="0" height="620" scrolling="no" width="1000" marginheight="0" marginwidth="0">
</iframe>
Here i'm calling UI_RegInc silverlight application, where UI_RegInc.aspx page is calling silverlight application that i want to debug.
What I tried was to start asp application, then in another instance of VS i launch silverlight applicaton, it is UI_RegInc, and in this instance
trying to attach it to iexplorer process with asp application. But getting no positive result. Also tried to attach to webdev process.
A cumbersome explanation, but hope will understand.

Add your ASP.NET and the Silverlight project to a common solution and the Visual Studio debugger will attach to the Silverlight application automatically while debugging the website project. You cannot attach two separate instances of Visual Studio to the same Internet Explorer instance, so you have to add both to the same solution and debug from there.
You can either add the Silverlight project to your existing ASP.NET solution (right click solution, Add -> Existing Project) or create a new solution for times you want to debug both at the same time (create a new blank solution and add the existing projects, same as before).
Here is the process to configure everything step-by-step after that. You can download this source files to the test solution here:
http://www.singulink.com/ClientFiles/StackOverflow/CrossProjectTest.zip
The projects are as follows:
CrossProjectTest - Silverlight 4 project
CrossProjectTest.Web - ASP.NET project that hosts the Silverlight application inside Index.html
IFrameWebApp - ASP.NET project that has an <iframe> pointing to Index.html in the other ASP.NET project
1) In the ASP.NET project that is hosting the Silverlight application, change the settings so it doesn't open a page when debugging and specify a port so that you can always reach it at a known address (which in this case will be http://localhost:18000). You don't want it to open a page because the IFrame ASP.NET project has the actual page you want to show. We still want it to hook the debugger into the web server process though, which is where step #3 will come in.
2) Point the src attribute of your iframe inside the IFrame project at the known address of the page that hosts the silverlight application in the other ASP.NET project, like so:
<iframe width="100%" height="100%" src="http://localhost:18000/Index.html"></iframe>
3) Right click on the solution file, and select Properties. Under "startup project" you will want to select "Multiple startup projects" and set the start action for both of your ASP.NET projects to "Start".
4) Make sure Silverlight debugging is enabled inside BOTH the ASP.NET projects, especially the IFrame project for this particular scenario:
5) Set a breakpoint in your Silverlight application, press F5, and everything should launch. Because you set both ASP.NET projects to start, it will fire up both development web servers but only one internet browser, pointed to the IFrame project. I added a breakpoint in the App Startup of the Silverlight project just to demonstrate it getting hit:
6) Press F5 to continue execution and Silverlight should show up in the IFrame, as can be seen here:
7) Happily place breakpoints in any of the three projects and Visual Studio will debug all of them!

You have to check Silverlight on your Web project that host Silverlighth application.

Related

Auto Build MVC app on after code behind change

In old sweet Web Forms times, when we make change on code behind, once we hit the application, it was compiling on the fly and running new changed code.
For Web Apps and MVC, when I add a new controller or change something on business logic, I have to always build app on VS 2015 manually and go back to browser and test again. But many times I keep forgetting building till I see yellow error screen.
Is there any way to kick build if there is code change and if I hit the website first time like Web Forms? I would not prefer to build on save since I am a ctrl + S freak, and keep pressing that combo on every other second.
To my knowledge Dynamic Compilation is not available in an MVC application because it won't be a "Web Site" project, it will be a "Web Application" project. Only Web Site projects can do dynamic compilation, since with MVC you're routing to actions in the controller my guess is it has to be compiled in advance - unlike ASP.NET where you're routing to a physical file.

How to call ASP.Net pages from a DLL?

I am developing a Web Application in Visual Studio 2008 (ASP.Net C#). My application currently has the following pages:
1. MasterPage.Master
2. Default.aspx
3. Login.aspx
4. Logout.aspx
5. ReportPrint.aspx
Now, I have to in-house-distribute this application to my Developers for further development. For that, I dont want to give pages such as Login.aspx, Logout.aspx, ReportPrint.aspx since they are already complete.
Hence, I compiled these forms in a separate Web Application to create a DLL. Now I am trying to refer to this DLL and call pages which are compiled in it, but without any success.
In windows forms, we can easily refer to Forms from a DLL using :
DllName.FormName.show()
How to accomplish this using ASP.Net?
The markup won't be part of the DLL; so as it currently stands you'll need to give the markup pages (.aspx files) to your team along with the compiled DLL (which will contain the code behind, ie aspx.cs).
See Sharing ASCX-controls between different web applications for other solutions.

Best practice for integrating a silverlight control in a Asp.Net Solution

I need some advice regarding the handling of a Silverlight control that I need to integrate into an existing Website, coded with Asp.Net.
I'm using SVN, Visual Studio 2010, Framework 4.0. I need to create a simple silverlight control and I need to have it embedded in one of my asp.net pages.
My question is basically, what is the best practice on where to put this Silverlight control?
1) Creating a new project for my Silverlight control and then refer to it through an external tools within my website? (importing only the .xap?)
+ Reuse
- Seems lot of extra work for a small control
2) Create a new project withing my website solution, compile it next to my website and create a post build event to copy the .xap generated into a ClientBin folders in my website?
- Lack of reusability
+ Easy to make small modifications in my Silverlight component.
3) Another solution I don't know yet??
Thanks for your advices
Do not worry about number of projects. Reuse is far more important (we have solutions with over 100 projects).
Create a new Silverlight application, then add a Silverlight relationship between the website and your new Silverlight application:
Right-click on your website project and select Properties.
Choose the Silverlight Applications tab on the left side
Press Add...
Leave Use an existing Silverlight project in the solution checked and select the project you want to add from the Project dropdown.
Leave Add a test page that references the control checked if you want a separate test page for your application.
Press Add and you are done.
The website will now build your Silverlight application and include the output Xap file in its ClientBin folder.
If you check "add a test page", that will give you sample HTML/ASPX pages and the JavaScript you need to run the Silverlight component anywhere in your ASP.Net app.

ASP.NET MVC - Quickest way to preview changes to page in MVC app using VS web server

I'm an ASP.NET Web Forms developer who has recently switched over to an MVC web app.
I'm having difficulty working out the quickest way to preview code changes when running the MVC web app through the integrated Visual Studio web browser.
In web forms, I can make a change to the codebehind and simply refresh the page and it's all good.
In MVC, I seem to have to close the tab in the browser, return to Visual Studio and press F5, wait for it to build every single dependent project and open up a new tab in the browser to display the page. This is so much slower than how it works in Web Forms it's driving me to distraction.
Am I doing things right? Is there a way to speed this cycle up?
The view pages themselves are compiled dynamically and thus any changes to these can be viewed simply by saving the changes and refreshing the pages in the browser. Changes to code made elsewhere, however, will require a rebuilt after which you can refresh the page.
Pressing F5 will start the web server (if it isn't already started) and then attach a debugger to the process after which it will fire up the web page. The first two steps are very slow, and you should avoid them unless you specifically need to start the web server or debug the application.
So
Changes to view: ctrl+s -> refresh web page (f5)
Changes to code: ctrl+shift+b -> refresh web page (f5)
I used to find setting my project to run via IIS, rather than Cassini, made it a bit quicker. If you've made changes to the code, you'll still have to compile the solution, but at least this way you aren't waiting for Visual Studio to slowly crank itself into gear every time.
Found this article that might provide some clues too:
What are the (dis)advantages of using Cassini instead of IIS?

ASP.NET javascript debugging does not work in 2 projects

I have 2 asp.net web applications, one of which is the main application and the second one is referencing the first application for like master pages , themes etc, and the main frameset that will point to the second application's webform based on database values (menu generated from database);
All my actual forms are in the second application, but the problem is when I set a breakpoint on the javascript file on my second application, it doesnt go into the breakpoint?
Any advice please? I need to get the debugger working, without having the need to put in the "debugger" keyword in javascript if possible.
My IDE is visual studio 2008 SP 1 and IE 8 as the browser.
Cheers
Do you have the solution set up to start up both projects with debugging when you start the debugger? To set multiple startup projects, right-click on the solution. Choose Set Startup Projects. In the dialog, select multiple startup projects and set the two web sites to start up with debugging when the debugger is started.
For what it's worth, I usually like to debug my javascript in Firefox with Firebug. I much prefer that to the developer tools in IE 8.

Resources