Hi,
I am working on changing the item url of sharepoint 2010 document library programatically. Once user click on a document in the library the document should redirect to the NewItemURL, for this I have written the below code but its not giving the expected result. Could somebody please help me out on this.
string oldItemURL = item.Web.Url + "/" + item.File.Url;
string NewItemURL = "/Sites/MyTestSite/_layouts/MyCustomApplicationPage/MyCustomApplicationPage.aspx?ItemId=" + docID;
item.Url.Replace(oldItemURL, NewItemURL);
item.Update();
Brijendra GautamPosted Mar 16, 2014, 11:47 PM
You are doing only string replacement and not assigned the output to any variable. And also item.Url is a readonly property so you cant directly replace it with some other url.
To achieve this task you need to implement custom handler that will process your request and redirect to new url.