MVC_Nhibernate
MVC_Nhibernate

Reputation: 457

How to provide a path of an html file to src attribute of Iframe in MVC3

I am having problem in providing a path to the IFrame src.

I hav kept my html file in the same directory.But still i dont get it

I wrote like this:

  <iframe id="iframe" frameborder="0" src="Dancing.htm" style="width: 100%; height: 700px;"></iframe>

But it gives me error as Resource Not found However if i write a view(.cshtml) page rather than HTM page it is loaded properly i am not undertsanding why this is happening

Please Help me.

Upvotes: 4

Views: 7624

Answers (2)

Yorgo
Yorgo

Reputation: 2678

You have to locate your *.html files out of Views folder.

Create HTML folder and copy your Dancing.htm file to that folder

/HTML/Dancing.htm

<iframe id="iframe" frameborder="0" src="@Url.Content("~/HTML/Dancing.htm")" style="width: 100%; height: 700px;"></iframe>

Upvotes: 5

RredCat
RredCat

Reputation: 5431

Check this article - URL Routing. Your cshtml page is routed. But htm not. So looks like it will work if you add path with directory name. From other hand you can add custom router. But to my mind it isn't good idea to keep htm and cshtml in same place.

Upvotes: 1

Related Questions