troubleshooting Question

How to use a MVC view to host a rendered React component in an iframe.

Avatar of Bruce_M
Bruce_MFlag for United States of America asked on
ASP.NETUI/UX.NET MVCMicrosoft Visual Studio
4 Comments1 Solution399 ViewsLast Modified:
I had this question after viewing How to use an iframe in mvc.

I'm building a web app for personal financial planning. I've started with a React framework to build the user's interaction, and that is going well. But now I want to use the new ASP.NET Core mvc framework for the main user interface, and use the react code in one of the mvc's views. But I am new to the plumbing used in ASP.NET Core mvc. I have a DOTNET CLI generated framework up and running in Visual Studio Code, with my react project embedded in an Areas folder. It all works in that I can run the mvc on local host by using the VSCode debugger facility, and I can run my react by using npm start to run the Webpack server for my react code under the Areas folder. I build my output in the Areas/frcstr/build folder and I want to provide that index.html to the mvc view to load the rendered React app.

My question is how do I create the empty view to hold the iframe tag? I tried to just use one of the boiler plate views in the generated mvc framwork, but that is compomised some how by Razor with common layouts and such. I just need a plain view to hold this:

<iframe src="../../Areas/frcstr/build/index.html" height="100%" width="100%" style="border:none;"></iframe>

At this point I don't know how to define Controlers, views, etc.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros