Navigating to a SharePoint 2013 library that contains a page named Default.aspx will open that page

I came across an interesting situation after clicking on the “View Library” link in some search results. Clicking on “View Library” resulted in a “something went wrong” error, but why?

"View Library" link in SharePoint search results
“View Library” link in SharePoint search results
Sorry, something went wrong
Sorry, something went wrong

So, why the error? First, notice that the link points to a folder name, and not a page: http://somewhere/Shared%20Documents/Folder.

After clicking on the link, I was taken to http://somewhere/Shared%20Documents/Folder/Default.aspx, instead of the default view for the folder “Folder”.

It turns out there was a file named “Default.aspx” in the folder of the library. Because of its file name, SharePoint automatically redirected to this file instead of displaying the default view for that folder.

SharePoint-Defaultaspx

I renamed the file, and immediately navigating to the folder URL redirected to the default view for that folder as expected:

http://somewhere/Shared%20Documents/Folder correctly redirected to http://somewhere/Shared%20Documents/Forms/AllItems.aspx?RootFolder=%2fShared%20Documents%2fFolder&CTID=0x01200021234567891234567891234567891234

The correct URL is nasty, but as you can see it specifies the default view “AllItems.aspx”, as well as the folder to display with the RootFolder parameter.

As for the “something went wrong” error, that was simply due to the contents of the “Default.aspx” file. It contained some invalid code, so the underlying exception (which I retrieved from the ULS logs) was System.Web.HttpException: Code blocks are not allowed in this file. In this case, the Default.aspx file wasn’t important anyway.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s