2009-03-24 7 views
3

Net 3.5 SP1 et de tenter d'implémenter un exemple de copie de http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx dans un exemple d'application Web, mais il semble y avoir quelques problèmes. Je suis sous Windows Vista, IIS 7.0, en mode intégré.Routage de formulaire Web - Impossible de créer une classe abstraite

Ci-dessous le YSOD:

Cannot create an abstract class.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Cannot create an abstract class.

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.

Stack Trace: [MissingMethodException: Cannot create an abstract class.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230 System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111 System.Web.Configuration.HandlerFactoryCache..ctor(String type) +57 System.Web.HttpApplication.GetFactory(String type) +78 System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +229 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

J'ai une interface qui ressemble à ceci:

public interface IRoutablePage : IHttpHandler 
{ 
    UrlHelper Url { get; } 
    HtmlHelper Html { get; } 
    RequestContext RequestContext { get; set;} 
} 

J'ai une classe abstraite (RoutablePage) qui hérite de cette interface et System.Web.UI .Page. J'ai alors une page web (attachée à une masterpage) qui hérite de la classe RoutablePage.

J'ai des routes d'installation dans ma configuration web et quand j'essaie d'accéder à http://local.url/pageName je rencontre le YSOD avec les informations ci-dessus.

Quelqu'un peut-il aider à résoudre ce problème s'il vous plaît?

Salutations

+0

Je pense que nous devons voir votre section web.config d'abord, puis éventuellement les classes – annakata

+0

Si vous téléchargez l'exemple de projet piraté, le fichier web.config est identique. –

Répondre

0

Le problème a été provisoirement résolu. Exécution du site Web sous IIS7 provoque le problème ci-dessus et l'exécution du site Web en utilisant cassini, chaque fonctionne comme prévu sans erreurs.

De plus amples informations sur ce problème seraient appréciées cependant.

4

J'ai eu le même problème. J'ai pu trouver une réponse sur ce forum http://forums.asp.net/t/1272109.aspx

Cross affichage ce qui m'a aidé:

In Web.config -> system.webserver -> handlers, replace

<add name="UrlRoutingHandler" 
preCondition="integratedMode" verb="*" 
path="UrlRouting.axd" 
type="System.Web.Routing.UrlRoutingHandler, 
System.Web.Routing, Version=0.0.0.0, 
Culture=neutral, 
PublicKeyToken=31BF3856AD364E35"/> 

With:

<add name="UrlRoutingHandler" 
preCondition="integratedMode" verb="*" 
path="UrlRouting.axd" 
type="System.Web.HttpForbiddenHandler, 
System.Web, Version=2.0.0.0, 
Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a" /> 
+0

Semble avoir travaillé pour moi aussi. Merci! – rball

Questions connexes