Link to home
Start Free TrialLog in
Avatar of Anjala Baby
Anjala BabyFlag for India

asked on

Window.Open() is showing a blank page

Hi,

I have to open a new window from one of my index page. So I have added Window.Open('../Home/Index.csHtml'). The new window is populating with a blank screen.

Regards,
Anjala
Avatar of Mukesh Yadav
Mukesh Yadav
Flag of India image

Here you need to pass absolute URL not relative one;

So in your case window.open('http://www.sitename.com/' + 'Home/Index.csHtml');
Avatar of Anjala Baby

ASKER

I need to open the window in a locally hosted application.
Then you can use the localhost in place of domain like this or whatever is your hostname:post if any http://localhost/Home/Index.csHtml
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're getting a blank page and if you look at the console you should have an error HTTP 404, page not found.

This is because csHTML files are not HTML files, they are MVC views that are processed by the MVC engine.
So what you need to use is the route that points to that view.
From the path you shared, big chances are that it's the root route, meaning just /
For instance:
window.open('/');

Open in new window

This will fail if you're running your site in a virtual directory, so take tat in consideration.
Yes. I am getting a blank page when giving Index.cshtml but there is no 404 error.

Also if I give Index instead of Index.cshtml, new window opened showing Access denied. Did I done anything wrong?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Guys..It worked.  I have given permission to my view.
While giving Index policy to view,  it worked.