Solved

How do I embedded a aspx page inside a razor cshtml file

Posted on 2014-11-29
5
449 Views
Last Modified: 2015-01-13
Hi,

I built a Responsive Design webpage with navigation menus with Bootstrap and MVC5.   I built it using Razor.    I have legacy aspx pages that uses a site.master file.   Is there a way to embed the aspx page inside my Webpage.   For example, I want the aspx page to show next to my navigation bar on the left side.   I currently redirect the View to the aspx page but it won't keep the navigation menus.   I hope this makes sense.   Thanks.

David
0
Comment
Question by:davidst98
  • 3
5 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 40471752
Depending on the type of output the page produces, you could use a server side include http://support.microsoft.com/kb/306575 or use ajax to inject the output to where you need.

If you don't need to pass a variable, then you can use an include file.  If you do need to pass a variable to the other page, than you will want to use ajax.

The only other option I can think of is not really a good option and that is to use an iframe.  The first two choices are the way I would go.

I am not a .NET developer and can minimally help on the specifics of these options.
0
 

Author Comment

by:davidst98
ID: 40471938
Thanks for the reply.   I tried the example and used Response.WriteFile but it just wrote the raw aspx file to the webpage and did not decode it.

David
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40471949
On that link I provided, if you look at the trouble shooting, it must be meant only for static html.  I use that all the time in classic asp.   It seems to not be the same in .net.  If that is the case, then an ajax call to that page is going to be the way to go.  
Server-side code in the dynamically included file is displayed on the client browser.

The dynamically included file may contain any client-side code, including HTML and JavaScript. If that file contains any server-side code, the server-side code is sent to the client browser as plain text and is visible if you view the source of the page that is displayed in the browser. Note that ASP.NET does not process server-side script in the dynamically included file. This is because all of the ASP.NET code has already run before it includes the file; thus, the server does not return to read anything for server-side processing again.
If you use Response.Write or Response.WriteFile statements in a code-behind module, these statements write the information before any HTML tags. The same behavior occurs if you use inline <SCRIPT> tags with the RUNAT="Server" attribute. 

Because the code-behind modules are compiled first, all of the output that is generated by Response.Write, Response.WriteFile, or inline server-side <SCRIPT> tags appears before any HTML tags when the HTML output is sent to the browser. This problem does not occur when you use Response.Write statements in classic ASP-style tags

Open in new window

0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40471950
I would also wait here to see if somebody who develops in .net has another option for you.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question