locked
Separate Web Pages within MVC Project RRS feed

  • Question

  • User2074931137 posted

    I have a web page that I created from Excel (save as / single web page).  I would like to incorporate this web page into an MVC project. 

    How does this get handled? Where would this get stored within the MVC project?

    Wednesday, December 19, 2018 1:42 PM

Answers

  • User475983607 posted

    3v3rhart

    I have a web page that I created from Excel (save as / single web page).  I would like to incorporate this web page into an MVC project. 

    How does this get handled? Where would this get stored within the MVC project?

    Place the file wherever you like within the root web application.  Perhaps create an "html" folder and place the file within the "html" folder.  Then create a controller and action to render the file using FilePathResult()

    public ActionResult Index()
    {
    	return new FilePathResult("~/html/myExcelFile.html", "text/html");
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 19, 2018 2:41 PM
  • User1520731567 posted

    Hi 3v3rhart,

    How do you want to call the file?

    You could return File in action as @mgebhard said.

    Or 

    You could also call the file in the View,like:

    @Html.Raw(File.ReadAllText(Server.MapPath("~/content/xxx.html")))
    

    This path is the address where your file is stored.

    And you could  pass any html as a string to @Html.Raw.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 20, 2018 7:53 AM

All replies

  • User475983607 posted

    3v3rhart

    I have a web page that I created from Excel (save as / single web page).  I would like to incorporate this web page into an MVC project. 

    How does this get handled? Where would this get stored within the MVC project?

    Place the file wherever you like within the root web application.  Perhaps create an "html" folder and place the file within the "html" folder.  Then create a controller and action to render the file using FilePathResult()

    public ActionResult Index()
    {
    	return new FilePathResult("~/html/myExcelFile.html", "text/html");
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 19, 2018 2:41 PM
  • User1520731567 posted

    Hi 3v3rhart,

    How do you want to call the file?

    You could return File in action as @mgebhard said.

    Or 

    You could also call the file in the View,like:

    @Html.Raw(File.ReadAllText(Server.MapPath("~/content/xxx.html")))
    

    This path is the address where your file is stored.

    And you could  pass any html as a string to @Html.Raw.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 20, 2018 7:53 AM