最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - asp.net MVC, redirect to view, view open new window to external url, it's getting treated as a view - Stack Overflo

programmeradmin1浏览0评论

Trying to put together a quick and dirty page to redirect to another website in a new window.

So I stash a url in the session, redirect to the page from mvcSiteMap, hit the page...

run this javascript

    $(document).ready(function () {
        window.open( '@HttpContext.Current.Session["EisUrl"].ToString();' );
    });


</script>

}

and instead of opening a new window pointing to google, I get the same window with this message.

The view '' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/ReportsManagement/ ~/Views/ReportsManagement/ ~/Views/Shared/ ~/Views/Shared/ ~/Views/ReportsManagement/ ~/Views/ReportsManagement/ ~/Views/Shared/ ~/Views/Shared/

So it's treating my external URL as if it's still internal to the website...

This seems like it ought to be pretty simple..... clearly I'm missing something obvious.

Any Help is appreciated.

Trying to put together a quick and dirty page to redirect to another website in a new window.

So I stash a url in the session, redirect to the page from mvcSiteMap, hit the page...

run this javascript

    $(document).ready(function () {
        window.open( '@HttpContext.Current.Session["EisUrl"].ToString();' );
    });


</script>

}

and instead of opening a new window pointing to google., I get the same window with this message.

The view 'http://google.' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/ReportsManagement/http://google..aspx ~/Views/ReportsManagement/http://google..ascx ~/Views/Shared/http://google..aspx ~/Views/Shared/http://google..ascx ~/Views/ReportsManagement/http://google..cshtml ~/Views/ReportsManagement/http://google..vbhtml ~/Views/Shared/http://google..cshtml ~/Views/Shared/http://google..vbhtml

So it's treating my external URL as if it's still internal to the website...

This seems like it ought to be pretty simple..... clearly I'm missing something obvious.

Any Help is appreciated.

Share Improve this question edited Sep 7, 2012 at 11:06 tereško 58.5k25 gold badges100 silver badges150 bronze badges asked Sep 6, 2012 at 21:42 Eric Brown - CalEric Brown - Cal 14.5k13 gold badges64 silver badges103 bronze badges 3
  • Your jovialscript is hitting your ASP.NET MVC server, and trying to execute teh controllers. – Robert Harvey Commented Sep 6, 2012 at 21:49
  • @DarthVader What do you mean? He accepts answers on 2/3 of the questions he asks. – Robert Harvey Commented Sep 6, 2012 at 21:49
  • Why negative rep? I answered it, it already has answers so I can't delete it, despite trying to... The behavior is illogical enough that someone else is likely to bump into it agian, so the answers might even be of help... I don't know what to have done differently. – Eric Brown - Cal Commented Sep 11, 2012 at 19:27
Add a ment  | 

4 Answers 4

Reset to default 3

Make sure what is being rendered from the session is the correct and well-formed URL as you would expect. I normally use window.location to redirect in javascript also.

Maybe totally out of scope, but can't you do this in the ActionResult ?

return Redirect("http://www.google.");

try

window.location = '@HttpContext.Current.Session["EisUrl"].ToString()';

I figured it out, i was being an id 10 t,

I had this in the view(razor)

@model string

and this in the controller

public ActionResult GetEisReportRedirect()
        {
            string url =  eisReportBLLHdl.DoGetEisReportRedirect(  );

            return View( url );// i was passing url here to the view
        }

So it' was trying to pass the string as a model, I decided i was unsure of the exact behavior and swapped to putting it in the session.. but left those in place.

For some reason, the string was getting interpteted as a URL, the fact that the new window was not openeing should have been a clue it was going off the rails early.

When I removed the line from the model and the url paramter from the return View()... it now redirects correctly (just not in a new page but I'll get that)

Thanks for all the help!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论