MVC2: "File not found" after view is painted - asp.net-mvc

This is wierd.
First, I'm building a site based on someone else's framework (Piers Lawson: Creating a RESTful Web Service using MVC ), so I'm not entirely sure what's going on under the covers. But when I run it in VS 2010 by pressing F5, it brings up the Home page, and THEN traps an error in Application_Error. The error is "File does not exist" exception. But I have no idea what file it's looking for. Where does flow control go after the View is finished displaying? How can I break to find out what it's looking for?

The error could be any other file reference in the page (Css, javascript or images).
Let VS to continue without halting and use FireBug to spot the file that is missing.

Related

Web API Help Pages not loading documentation XML

I'm trying to set up the ASP.NET Help Pages to run in an existing MVC project, though pointing towards the documentation file from a Web API project in the same solution. Convention has the Help Pages running inside the Web API that it's documenting but in this case I want it in a sibling MVC project.
The Web API project outputs its documentation XML file in a folder within the MVC project.
I've installed the Microsoft.AspNet.WebApi.HelpPage NuGet package in the MVC project. This creates a class \Areas\HelpPage\App_Start\HelpPageConfig.cs, and within this class's Register method I've passed the XmlDocumentationProvider the path to the Web API's documentation file.
But when I load the page, it's empty, aside from a title and a placeholder description.
Upon debugging the HelpController.Index method, I can see in the returned IApiExplorer that the _apiDescriptions are empty.
However, if I install the Help Pages directly into the Web API project and debug the same method, I can see that the _apiDescriptions are now present.
Can anyone explain what the Web API project is doing or has configured which the MVC project isn't doing or hasn't configured?
Just set this up myself, and I think I ran into a similar issue, if i'm reading what you're saying correctly.
Try the following:
Go to Areas\HelpPage\App_Start\HelpPageConfig.cs. Around line 36, you'll want to make sure you uncommented the line as below:
//// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/ApiDocumentation.xml")));
And make sure the path is correct. I happened to put my xml file in the App_Data directory.
Go to Project=>Properties=>Build. Under Output, make sure the "XML documentation file" box is checked, and point it to App_Data\ApiDocumentation.XML (assuming you put it in the same place i did above.
If i remember correctly, i had to make sure i added the .xml file to the project- i had some problems when i tried publishing it to our test server at work and it said the file couldn't be found. After you build, simply go to App_Data, right click on the folder, and add existing item. navigate to App_Data in your file system and select the xml file.
This will hopefully fix your problem!
I'm not sure if this will help anyone else that stumbles across this, I had started with a blank template from VS and added the help files via the Nuget package.
Because it was a blank template and I had no areas set up, it was missing the following from the global.asax
AreaRegistration.RegisterAllAreas();
This prevented the HelpPageConfig.Register from being called and thus, the Xml Documentation provider was never set.

Hyperlink from Microsoft Word .doc causing Invalid Browser Error

I've run into a bug where my website will not allow a user to click a valid hyperlink from a microsoft word document (2010, 2013 tested) and correctly go to the website.
The website is using MVC architectural patterns, so any action such as index, help, etc do not work.
Has anyone ran into this issue, if so, how was it resolved? I can't seem to find any other issues like this being listed.
It would be helpful to see the exact error message - was it "invalid browser error"? Errors like that are usually related to an issue with Internet Explorer trying and failing to handle the URL, even though it may not be your default browser.
See here and here.

Umbraco 6 - Published page throws 404 in specific scenarios

I am running an instance of Umbraco 6.1.x and it has started throwing 404 on published pages.
My page structure is as follows,
Content
Home
About
Course
...
Component
Home
About
Course
Where component holds all resources and modules (HTML sections and stuff) for a page and using a partial view macro I dynamically load all components at runtime for a specific page.
We are facing an issue where we get 404 on every page after a full republish once we hit the HomePage. Before hitting home page they are all fine, but the moment we hit the homepage they are all throwing 404. By overriding the handlers I found out that they are hitting ~/umbraco/RenderMvc!
Any idea what can cause this?
Thanks in advance.
EDIT:
It is actually throwing:
No template exists to render the document at url '/'
considering the aforementioned scenario.
I have proper allowed template setup and property on nodes are showing the correct template associated with the respective items. Not sure why it's losing template info. I can force it to load under correct template using ?altTemplate=templateName.
Some pointers, we have a view in Views/Shared folder (apart from macro partials) tied to a surface controller.
One thing I would like to say is, we are using nested (library.RenderMacroContent with Umbraco markup) in our partial views and I have realized that the whole page throws 404 if there's a page with a link to the broken page which is broken (i.e. page got re-created and on t==e of the components is holding a link to the page with previous id). Suggestions?
did you get to the bottom of this? We're having exactly the same problem at the moment, on the same version of Umbraco.
I've noticed that when it happens, the umbraco.config becomes either corrupt or rolls back to a much, much earlier version, with all sorts of attributes missing. This lead us to believe it was a sync issue between the DB and umbraco.config.
We initially thought we had solved it by deleting App_Data > TEMP > ExamineIndex and recycling the app pool etc. Maybe give this ago, as it fixed it for a while for us, but alas, the demon has reared its ugly head once more. We are still in a full on dev stage though, so the constant changing may be complicating it further for us - perhaps it will be a fix for you.
If you have any more info, or even a fix, it would be greatly appreciated.
Cheers
EDIT:
Ok, I think I've solved this now, but only time will tell. Try emptying your recycle bin & then republish entire site.
I managed to consistently recreate the bug using IIS SEO site analysis. Each time I did this, the log threw up an error 'cannot find node id xyz', turns out that (and other) nodes were in the recycle bin. Upon emptying it the errors stopped. Good luck!

ASP.NET MVC Unknown server tag error

I was wondering why could I have not caught this issue in local testing? I am using a Content Panel user control in all my user controls. In one of the user control I missed the register tag for Content Panel UC. While testing locally all things were working fine . Suddenly on our QA box I got a critical issue. Application was throwing Unknown server tag 'cc1:ContentPanel' in the Landing page.
Can anyone explain why it was not caught locally?
Most likely there is a mismatch in your web.config files.
Use a diff program to compare the web.config on QA against the web.config on your box.
I bet you'll find the problem there...

Should cs files be deployed when publishing an ASP.Net MVC application?

I have a project that compiles and runs fine on my development machine but when I run it on the web server I get the following error.
Parser Error Message: The file '/Views/Shared/Main.master.cs' does not exist.
The file mentioned does not exist on the server but the file '/Views/Shared/Main.master' does.
I use the 'Publish' command to upload the project. Is it missing the cs files?
Is there some setting where it does just in-time compiling that need to turn off?
I stumbled upon this solution.
The master page has the following attribute CodeFile="Main.master.cs". When I replaced this with CodeBehind="Main.master.cs" it works as expected.
The file originally came from an older web application but I don't know what the difference means. If someone else can come up with a better explanation I will accept their answer instead of this one.
Glad you got it figured out. It may come from an issue when converting from "Web Site" to "Web Application" project type.
http://aspadvice.com/blogs/ssmith/archive/2007/01/24/CodeFile-or-CodeBehind.aspx
Usually the files are marked with a reference to a dll that exists in the bin, e.g. App_Web_nnnnn in the inherits declaration of Main.master. Is that the case for that file on the web server and does the referenced dll exist in the bin? If not then it may not be pre-compiling as it should.
As far as I have seen with MVC, I don't think you even need the code-behind pages, do you?
I have removed the references from any pages in my app that were there for any reason.
Also, when you create a new View, I don't think it even creates the code-behind page in MVC, does it? (Really threw me to start with!!)

Resources