Last post Jul 09, 2014 03:19 PM by Mikesdotnetting
Jul 09, 2014 06:24 AM|Chris17|LINK
Is there a way I can find the current page rendered by RenderBody() or RenderPage(). Thanks
Jul 09, 2014 08:52 AM|Afzaal.Ahmad.Zeeshan|LINK
I am sorry, I was not able to understand your question but still, I think I would give you the Idea.
The RenderBody() is used to render the main code for the body element of the page that is using the Layout specified. Something like this
Layout = "~/_SiteLayout.cshtml"; // startersite layout
Then in the Layout file, you'll find this code.
That is the part where the entire of the BODY element content is placed, You cannot tell the Script to get the Page for you. Somehow, you can use this trick.
var pageUrl = Request.Url;
This would get the URL for you in this format
You can always extract the value for the your_page from the URL that you're having. That way you can get to know, which page is being utilized here.
Jul 09, 2014 09:29 AM|Mikesdotnetting|LINK
You can use the VirtualPath property. The following will give you the current file's virtual path:
Jul 09, 2014 10:13 AM|Chris17|LINK
You can always extract the value for the your_page from the URL that you're having. That way you can get to know, which page is being utilized here
Ok. Please how do I extract that portion of the url so as to exclude the host name and folders
Jul 09, 2014 10:28 AM|Mikesdotnetting|LINK
You can use System.IO.Path.GetFileName(Request.Url.ToString()). That will give you the file name that was requested but not the name of a the file used as RenderPage, or didn't you want that?
Jul 09, 2014 10:56 AM|Chris17|LINK
Is there a way I can use it to get a parent folder?
To Get the folder Customer
Jul 09, 2014 03:19 PM|Mikesdotnetting|LINK