0

I am currently developing a SharePoint visual web part farm solution. I'm having trouble determining how without hardcoding a link to get from http://sharetest/sites/Dev/_layouts/15/HelpDesk/EditWorkOrder.aspx?2 to http://sharetest/sites/Dev/SitePages/Tickets.aspx. I shouldn't have to type in /sites/dev as when I move it to the live SharePoint it will be wrong.

I have tried many variations and can't seem to find one that works.

//Response.Redirect("http://sharetest/sites/Dev/SitePages/Tickets.aspx"); Response.Redirect("~/SitePages/Tickets.aspx");

1 Answer 1

1

You can get web absolute url and concatenate it with "/SitePages/Tickets.aspx".

On Client side:

<script type="text/javascript">
var YOUR_URL = _spPageContextInfo.webAbsoluteUrl + "/SitePages/Tickets.aspx";
Response.Redirect(YOUR_URL);
</script>

On Server side:

SPWeb curWeb = SPContext.Current.Web;
string YOUR_URL = curWeb.Url + "/SitePages/Tickets.aspx";
Response.Redirect(YOUR_URL);
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.