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?
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.
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.