OpenRasta with a default Index.html page? - openrasta

I'm working on a site that will use OpenRasta to deliver JSON data, and then use a think JavaScript client to perform all the interactions.
What we'd like to do is have an index.html page get served at the root. Currently we can get to the page by doing baseuri/index.html but simply going to baseuri doesn't take us there.
Is there a way I can get OR to deliver /index.html by default?
If it matters, I'm using the OR3 beta version.
Edit
First, I rolled back to OR 2.1. Just because I'd already worked with it and wanted to eliminate any unfamiliarity.
Second, I've got the following in my Web.Config file:
<defaultDocument enabled="true">
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
I'm getting a 404.0
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Detailed Error Information
Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler OpenRasta
Error Code 0x00000000
Requested URL http://localhost:80/
Physical Path D:\deployments
Logon Method Anonymous
Logon User Anonymous
Failed Request Tracing Log Directory C:\inetpub\logs\FailedReqLogFiles

Related

Published website, but it now displays an error page instead of homepage

The error states:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Here's the address where you can see the error:
http://connellchamberofcommerce.com/
I have a feeling there's something in the web.config I'm supposed to change now that the website is online instead of my local machine, but this is my first ASP.Net website and I don't know what it is.
Is there something simple I'm missing that you're supposed to do when publishing an ASP.Net website?
In order to diagnose errors for your initial deployment, you can make the following change to your web.config.
<configuration>
...
<system.web>
...
<customErrors mode="Off" />
...
</system.web>
...
</configuration>
You should change this back to RemoteOnly when you have resolved all your deployment exceptions to prevent unsavory folks from learning too much about your architecture.

Forms Authentication not redirecting

I am trying to incorporate forms authentication into my web application. If I try to load any page without logging in it will not redirect the user to the login page but instead load the requested page. As an example if I try to load ~/Home/About without logging in it will proceed to load the page without redirecting me to ~/Account/Login. This is the first time I have tried to implement form authentication and I am struggling to see the problem.
I believe I have added the correct settings to the web.config file on the root. They are as follows.
<system.web>
<authentication mode="Forms">
<forms name="chasAuth" loginUrl="~/Account/Login"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
I have another web.config file that resides in the Views folder. I have also tried to add these setting to this file however this results in a different problem. I get the following error message:
Description: An error occurred during the processing of a configuration file >required to service this request. Please review the specific error details >below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as >allowDefinition='MachineToApplication' beyond application level. This error >can be caused by a virtual directory not being configured as an application in >IIS.
I have tried to configure the virtual directory as an application in IIS as my research into the error has suggested however I can't seem to find the application in IIS. I am using localhost, or the ASP.NET Development Server, to debug my code. It is not up on a server yet. Would this be the issue?

MVC site deployed on Azure returns error when accessing elmah

I have an MVC WebAPI site that has the latest ELMAH.MVC NuGet package installed. Under Visual Studio, I can access
http://localhost:1234/elmah
and get the error log, just like I'm supposed to be able to.
When I deploy it to Azure, it throws an error when I do that. Fortunately, Elmah is logging the error to the XmlError log in App_Data, and I found this:
<error errorId="92ad3ee1-3fd5-449a-8cb4-0474aa771aab"
application="/LM/W3SVC/417796901/ROOT"
host="RD00155D430783" type="System.Web.HttpException"
message="Server cannot set status after HTTP headers have been sent."
source="System.Web"
detail="System.Web.HttpException (0x80004005): Server cannot set status after HTTP headers have been sent.
And then goes on for many lines of stack trace, NONE of which comes anywhere near my code.
What's going on? I've just added the Elmah.MVC nuget package, and made the following changes to the Web.Config
<elmah>
<security allowRemoteAccess="yes"/>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
<location path="elmah.axd">
<system.web>
<allow roles="*" />
</system.web>
</location>
It's not coming anywhere near any of my controllers, so I don't have any control over when Http status headers are set or sent.
Thanks for any help.
itanex is right! Put an empty text file (i.e. placeholder.txt) in the App_Data folder and mark it as "Content" and "Always Copy" - This will ensure that the App_Data folder is getting created. Also, as Simon point out, the correct path (based on your config) is /elmah.axd
via https://stackoverflow.com/a/11680786/1037948:
Allow remote access:
<elmah>
<security allowRemoteAccess="true"/>
</elmah>

MVC Area Error Handling

I have a MVC project set up with 3 areas. In the main project I have error handling set up
using custom errors in the web.config.
<customErrors mode="On" defaultRedirect="~/Error/HttpError">
<error statusCode="404" redirect="~/Error/Http404" /> </customErrors>
This cause the site to redirect to a error controller in the root and then show the error view.
This works OK in the root site, however when I throw an exception in the home controller of one
of the area sites it the message below.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.
Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".
Is it the case that error handling in the root site cannot be used in the area sites?
Thanks
John.
Does the area have it's own web.config that might be setting it's own error handling options? Can you put a breakpoint in Application_OnError to see if another error is occuring (eg. one loading the error page - eg. if you've turned off Buffering, it won't be able to do the redirect)?
You could also try adding the something like this to the main web.config to see if it it makes any difference:
<location path="nameOfArea">
<system.web>
<customErrors mode="On" defaultRedirect="~/Error/HttpError" />
</system.web>
</location>

asp.net trust level error

I deployed an asp.net mvc application and everything worked except for my Gallery page that streams pictures using flickr api. I get the following error.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I went into my web.config file and changed
<location allowOverride="true">
<system.web>
<trust level="Full">
And then the site will not run at all, I get the following error
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using
location allowOverride="false"
from an inherited configuration file.
Source Error:
</customErrors>-->
<trust level="Full" />
<pages>
<controls>
The webpage is oneotacycles.com
Any thoughts? Thanks very much!!
As above, it looks like Flickr is trying to make a cache on the server, have you checked that particular folder has write permissions?
This may help, http://flickrnet.codeplex.com/Thread/View.aspx?ThreadId=24550
Inside the constructor for the Flickr
class there is a call that tries to
load the default settings from the
configuration file (i.e. web.config).
If you are running in a restricted
security environment (such as a hosted
web site with an ISP) then you might
not be allowed to put new config
sections inside a web.config file so
when it parses the file a security
exception is thrown. It will do this
anytime you create an instance of the
Flickr class.

Resources