Solved

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

Posted on 2014-11-29
5
382 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now