Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:37:07+00:00 2026-06-18T00:37:07+00:00

I’m not sure if this is a common scenario but I couldn’t find anything

  • 0

I’m not sure if this is a common scenario but I couldn’t find anything on Google on how to do this.

In my Model I have a string property that contains the entire html for an external website. I want to display this html on my page to display the webpage as a whole, along with a few other controls at the top of the page.

For example, consider I have a div at the top of the page with a search box. I want to enter a url into that box and display it in a div below. My code behind retrieves the webpage markup as a string.

Note: There seem to be solutions using an iFrame, but I don’t wish to pass a URL. I want to retrieve the html as a string and display it that way.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:37:08+00:00Added an answer on June 18, 2026 at 12:37 am

    I think your going to have to use an iFrame – however it’s not all bad! you can still display your string.

    Controller will look like this:

    public class HomeController : Controller
    {
        //
        // GET: /Home/
        //Initial landing page
        public ActionResult Index()
        {
            return View("");
        }
        //for full postbacks, sets the iframes src on the index view
        public ActionResult Page(String url)
        {
            String myurl = "/Home/Search?url=" + url;
            return View("Index", model: myurl);
        }
        //for the iframes src attribute
        public ActionResult Search(String url)
        {
            //replace pageContent with your html string
            String pageContent = "<html><head><title>this is the title</title></head><body>this is the body</body></html>";
            return Content(pageContent);
        }
    }
    

    Index will be your landing or “Search” page,
    Page will be where your form posts to if javascript isn’t supported,
    Search will be where you will point your iFrame at.

    Action:

    @model String
    @{
        ViewBag.Title = "URLer";
    }
    <script type="text/javascript">
        $(document).ready(function () {
            $('#searchForm').submit(function (e) {
                e.preventDefault();
                $('#page').attr('src', '/Home/Search?url=' + $('#url').val());
                return false;
            });
        });
    </script>
    <div>
    @using (Html.BeginForm("Page", "Home", FormMethod.Get, new { id = "searchForm" }))
    {
        <input id="url" name="url" type="text" />
        <input id="Search" type="submit" value="Search" />
    }
    </div>
    <iframe id="page" src="@Model" width="100%" height="500">
    </iframe>
    

    this shows a search box and submit button, using jQuery the form submit sets the src attribute of the iframe to the search action, i.e. “/Home/Search” and add the value of the url textbox as part of the query string, this will then trigger the iFrame to navigate to the url being set (/Home/Search?url=http://google.com as an example), WHERE you are returning your own raw html page/string instead of the actual website.

    The form is a safety net and is probably not needed, however if for whatever reason javascript is disabled, the form will post to /Home/Page?url=http://google.com where the returned view will have the iframe set, and thus will get the url from our Search action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
Seemingly simple, but I cannot find anything relevant on the web. What is the
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.