When I make a call to an API an error is displayed:
"Could not load file or assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
Code
I have a base controller for my APIs
[BreezeNHController]
public class baseApiController<T> : ApiController
where T : class, IEntity
{
public IRepository<T> Repositorio { get; private set; }
[HttpGet, BreezeNHQueryable(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 20)]
public IQueryable<T> Get()
{
return Repositorio.All();
}
// ..
}
And implementation:
[BreezeController, Authorize]
public class usuariosController : baseApiController<User>
{
public usuariosController(IUserRepository repositorio)
: base(repositorio)
{ }
}
Url: GET /api/usuarios throw a exeption!
But my DDL is in reference:
Full response errror:
{
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'Breeze.WebApi.BreezeControllerAttribute' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at Breeze.WebApi.BreezeControllerAttribute.Initialize(HttpControllerSettings settings, HttpControllerDescriptor descriptor)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()\r\n at System.Lazy`1.CreateValue()\r\n at System.Lazy`1.LazyInitValue()\r\n at System.Lazy`1.get_Value()\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load file or assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
"ExceptionType": "System.IO.FileNotFoundException",
"StackTrace": " at Breeze.WebApi.JsonFormatter.Create()\r\n at Breeze.WebApi.BreezeControllerAttribute..cctor()"
}
}
Attempts
In the package manger console, run the command Add-BindingRedirect.
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
Found strange is not pointing to the 4.0. Can it be the problem? If yes, why Add-BindingRedirect did not work?
This is most definitely a binding redirect issue. I advice you copy the entire <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> content from a fresh ASP.NET MVC 4 project to your web.config file. This happens to me occasionally and refreshing the messed up bindings fixes the issue.
Related
I made the following changes to my DbContext
//public DbSet<Role> Roles { get; set; } //old
//public DbSet<TypePermissionObject> TypePermissionObjects { get; set; } //old
//public DbSet<User> Users { get; set; } //old
public DbSet<PermissionPolicyRole> Roles { get; set; }
public DbSet<PermissionPolicyTypePermissionObject> TypePermissionObjects { get; set; }
public DbSet<PermissionPolicyUser> Users { get; set; }
Now the following line of code is returning an error. When it should be returning false.
var compatible = db.Database.CompatibleWithModel(false);
The call stack is
Application: MyApp2.Win.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
at System.Linq.Enumerable.Single[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>, System.Func`2<System.__Canon,Boolean>)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer+<GetStoreAssociationTypePairs>d__15.MoveNext()
at System.Linq.Enumerable+<SelectManyIterator>d__23`3[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at System.Linq.Enumerable+<DistinctIterator>d__64`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.FindAssociationTypePairs(System.Collections.Generic.ICollection`1<System.Tuple`2<System.Data.Entity.Core.Metadata.Edm.EntityType,System.Data.Entity.Core.Metadata.Edm.EntityType>>)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata, ModelMetadata, System.Lazy`1<System.Data.Entity.Migrations.Infrastructure.ModificationCommandTreeGenerator>, System.Data.Entity.Migrations.Sql.MigrationSqlGenerator, System.String, System.String)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(System.Xml.Linq.XDocument, System.Xml.Linq.XDocument, System.Lazy`1<System.Data.Entity.Migrations.Infrastructure.ModificationCommandTreeGenerator>, System.Data.Entity.Migrations.Sql.MigrationSqlGenerator, System.String, System.String)
at System.Data.Entity.Internal.InternalContext.ModelMatches(System.Data.Entity.Migrations.Infrastructure.VersionedModel)
at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean, System.Data.Entity.Internal.DatabaseExistenceState)
at System.Data.Entity.CreateDatabaseIfNotExists`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].InitializeDatabase(System.__Canon)
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(System.Action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.RetryAction`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].PerformAction(System.__Canon)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(System.Action`1<System.Data.Entity.Internal.InternalContext>)
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Count[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Linq.IQueryable`1<System.__Canon>)
at MyApp2.Win.Program.Main()
I have double checked the connection string
The projects reference EntityFramework 6.4.4
Event Viewer shows that the Source of the Error is .NET Runtime
Crosschecking the error time with output from Process Monitor ( from sysinterenals.com ) I see a NAME NOT FOUND error for EntityFramework.pdb
4 milli seconds earler there is a NAME NOT FOUND error for BiDInterface
The answer to this question indicates that I might have duplicate entries in my database. I am not sure what is meant.
I tried changing to the following but it did not help/
public DbSet<PermissionPolicyRole> Roles2 { get; set; }
public DbSet<PermissionPolicyTypePermissionObject> TypePermissionObjects2 { get; set; }
public DbSet<PermissionPolicyUser> Users2 { get; set; }
[Update]
I decided to delete the migrations and generate a new one.
When I attempted this I got the following error in the PM Console
PM> add-migration security
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<GetStoreAssociationTypePairs>d__15.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__23`3.MoveNext()
at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.FindAssociationTypePairs(ICollection`1 entityTypePairs)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
at System.Data.Entity.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges)
at System.Data.Entity.Infrastructure.Design.Executor.ScaffoldInternal(String name, DbConnectionInfo connectionInfo, String migrationsConfigurationName, Boolean ignoreChanges)
at System.Data.Entity.Infrastructure.Design.Executor.Scaffold.<>c__DisplayClass0_0.<.ctor>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)
Sequence contains no matching element
PM>
I have the following in the DbContext
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Configurations.Add(new RoleConfiguration());
modelBuilder.Configurations.Add(new UserConfiguration());
}
with
public class RoleConfiguration : EntityTypeConfiguration<DevExpress.Persistent.BaseImpl.EF.PermissionPolicy.PermissionPolicyRole>
{
public RoleConfiguration()
{
HasMany(x => x.Users).WithMany(y => y.Roles).Map(x => x.ToTable("PermissionPolicyUserPermissionPolicyRoles"));
}
}
public class UserConfiguration : EntityTypeConfiguration<DevExpress.Persistent.BaseImpl.EF.PermissionPolicy.PermissionPolicyUser>
{
public UserConfiguration()
{
HasMany(x => x.Roles).WithMany(y => y.Users).Map(x => x.ToTable("PermissionPolicyUserPermissionPolicyRoles"));
}
}
[Update]
I studied a new xaf project and realised that the configurations are not needed.
Now I try to run the migration without the configuration files I get
PM> add-migration security
ystem.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<GetStoreAssociationTypePairs>d__15.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__23`3.MoveNext()
at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.FindAssociationTypePairs(ICollection`1 entityTypePairs)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
at System.Data.Entity.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges)
at System.Data.Entity.Infrastructure.Design.Executor.ScaffoldInternal(String name, DbConnectionInfo connectionInfo, String migrationsConfigurationName, Boolean ignoreChanges)
at System.Data.Entity.Infrastructure.Design.Executor.Scaffold.<>c__DisplayClass0_0.<.ctor>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)
Sequence contains no matching element
PM>
I think have done the security table upgrade in the wrong order.
I will need to roll back and proceed more carefully.
I have created One Filter Attribute
public class AuthFilterAttribute : System.Web.Http.Filters.ActionFilterAttribute
{
public AuthFilterAttribute()
{
}
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
}
}
I have registered this filter inside the global.asax.cs.
When I am trying to call my web API using Postman it is showing the error:
Method not found: 'System.Net.Http.HttpRequestMessage System.Web.Http.Controllers.HttpActionContext.get_Request()'.
My project target framework is 4.6.1 and the System.Net.Http version is 4.2.0.0
My API looks like this:
[AuthFilter]
public class ScheduleApiController : BaseApiController
{
[Route("api/v1/schedules")]
[HttpGet]
public IHttpActionResult GetSchedules()
{
}
}
I know this question has been asked before but none of the solutions worked for me.
Please help me to resolve this issue.
Are you referencing a .NET Standard Library by any chance. I ran into this problem and solved it with a Binding Redirect:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
You could try to enable the auto-generate bindings.
Right Click on your project --> Properties --> Application
Tick that
All of a sudden my app won't display a page and I now get "You do not have permission to view this directory or page." I looked at this but the suggestions there didn't help.
for my code:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
// NOTE: If this class is renamed, remember to update the global.asax.cs file
public class Service
{
[WebGet(UriTemplate = "")]
public string GetTest()
{
return "Windward update REST service running.";
}
}
When I request an aspx page, it works.
Global.asx.cs:
public class Global : HttpApplication
{
private static readonly ILog log = LogManager.GetLogger(typeof(Global));
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
log4net.Config.XmlConfigurator.Configure();
log.Info(string.Format("Update REST server started, running under user {0}", WindowsIdentity.GetCurrent().Name));
}
private void RegisterRoutes()
{
// The class providing the REST service
RouteTable.Routes.Add(new ServiceRoute("Service", new WebServiceHostFactory(), typeof(Service)));
}
web.config (relevant parts):
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
Nothing substantive has changed. So why do the requests no longer call the service?
thanks - dave
We have 2 roles which use a cache role to share data. When we deploy we get many many of the following entries in the logs:
INFORMATION: <CASClient> Updated partition table to (1-901) generation: 635036190744461419:0 with transfer (1-901) generation: 635036190744461419:0; TraceSource 'w3wp.exe' event
INFORMATION: <Complaint> Add hard complaint :0 ; TraceSource 'w3wp.exe' event
Changing the values of the setting:
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="0" />
seems to have no effect.
Any ideas how we can remove this noise from the WADLogs table?
It seems there is a bug in Caching (see this post). I tried to get rid of these log entries with no luck running SDK1.8. Recently I switched to SDK2.0 but unfortunately the problem is still not fixed.
Bug report on GitHub
I'm going to be adding a filter for this.
Sample for web.config:
<system.diagnostics>
<trace>
<listeners>
<add name="console" type="System.Diagnostics.ConsoleTraceListener">
<filter type="Namespace.TraceFilter, Assembly" initializeData="Information"/>
</add>
</listeners>
</trace>
</system.diagnostics>
Note: The attribute initializeData is set to the text from System.Diagnostics.SourceLevels enum. See here.
TraceFilter.cs
public class TraceFilter : EventTypeFilter
{
public TraceFilter(SourceLevels level)
: base(level) {}
public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string formatOrMessage, object[] args, object data1, object[] data)
{
return !Regex.IsMatch(formatOrMessage, "INFORMATION: <[^>*]*>");
}
}
You could extend this to a more generic filter which could run off a configuration accepting different patterns to include/ignore.
After reading a suggestion at the end of this thread on GitHub we managed to disable this by running the following code in the application:
DataCacheClientLogManager.ChangeLogLevel(TraceLevel.Off);
DataCacheClientLogManager.SetSink(DataCacheTraceSink.DiagnosticSink, TraceLevel.Off);
This stops all logging from the Azure Cache Client without you having to turn off your own Warning or Information level logs.
We ended up adding this in the constructor of our Cache Provider wrapper around the DataCacheClient:
public class AzureCacheProvider : ICacheProvider
{
public AzureCacheProvider()
{
DataCacheClientLogManager.ChangeLogLevel(TraceLevel.Off);
DataCacheClientLogManager.SetSink(
DataCacheTraceSink.DiagnosticSink,
TraceLevel.Off);
InitializeCache();
}
Here is a complete solution
Just make sure to use your namespace and corresponding assembly name.
using Microsoft.WindowsAzure.Diagnostics;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace MyNamespace
{
/*
Solves the Azure In-Role Cache client warnings bug which is too verbose in the WAD logs
Also Solves Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener not using Filter
For roles which uses in-role caching, configure your Web.config or app.config with the following system.diagnostics listner and filter:
<system.diagnostics>
<trace>
<listeners>
<add name="AzureDiagnostics" type="MyNamespace.FilteringDiagnosticMonitorTraceListener, MyAssemblyName">
<!-- WARNING: does not work with type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
because the DiagnosticMonitorTraceListener does not call the filter's ShouldTrace method as is was supposed to... -->
<!-- Note: working with type="System.Diagnostics.ConsoleTraceListener" -->
<filter type="MyNamespace.SuppressCacheClientWarningsTraceFilter, MyAssemblyName" initializeData="Information"/>
<!-- Note: The attribute initializeData is set to the text from System.Diagnostics.SourceLevels enum. -->
</add>
</listeners>
</trace>
</system.diagnostics>
*/
/// <summary>EventTypeFilter which suppress the 'noise' messages from the In-Role Azure Cache client
/// </summary>
/// <remarks>It's a workaround for the following problem http://social.msdn.microsoft.com/Forums/windowsazure/en-US/7ebbc44e-7b61-4bbe-aa54-a85a7788079f/complaint-add-hard-complaint?forum=windowsazuredata.
/// The solution is based on http://stackoverflow.com/questions/16443856/how-to-suppress-azure-cache-client-warnings-from-the-wad-logs and http://pastebin.com/qKc1aTTW
/// </remarks>
public class SuppressCacheClientWarningsTraceFilter : EventTypeFilter
{
public SuppressCacheClientWarningsTraceFilter(SourceLevels level)
: base(level) { }
public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string formatOrMessage, object[] args, object data1, object[] data)
{
return !(
(eventType == TraceEventType.Information && Regex.IsMatch(formatOrMessage, #"^INFORMATION:\ <(CASClient|Complaint)>"))
|| (eventType == TraceEventType.Warning && Regex.IsMatch(formatOrMessage, #"^WARNING:\ <SimpleSendReceiveModule>\ DeadServerCallback"))
);
//return !Regex.IsMatch(formatOrMessage, #"^INFORMATION: <[^>*]*>");
}
}
/// <summary>Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener which uses the configured Trace Filter
/// </summary>
/// <remarks>It's a workaround for the following problem http://social.msdn.microsoft.com/Forums/en-US/92ed1175-d6b7-4173-a224-0f7eb3e99481/diagnosticmonitortracelistener-ignors-filter?forum=windowsazuretroubleshooting
/// The solution is based on the thread comment from "Qin Dian Tang - MSFT": "If you need to use trace filter, then it is needed to use a custom trace listener which derives from DiagnosticMonitorTraceListener, override TraceData, and either manually check filters or call the root class's (TraceListener) TraceData."
/// </remarks>
public class FilteringDiagnosticMonitorTraceListener : DiagnosticMonitorTraceListener
{
public FilteringDiagnosticMonitorTraceListener() : base() { }
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
{
if (this.Filter == null || this.Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null))
base.TraceEvent(eventCache, source, eventType, id, format, args);
}
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
{
if (this.Filter == null || this.Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null))
base.TraceEvent(eventCache, source, eventType, id, message);
}
}
}
Hope it helps.
I made a custom handler for test purposes, which looks like:
namespace MVCHttpHandlerProject
{
public class SomeHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.Write("SomeHandler test");
}
}
}
Then I added to my web.config next lines:
<httpHandlers>
<add path="SomeHandler.axd" verb="*" type="MVCHttpHandlerProject.SomeHandler, MVCHttpHandlerProject" /></httpHandlers>
and in <system.webServer>
<handlers>
<add path="SomeHandler.axd" verb="*" type="MVCHttpHandlerProject.SomeHandler, MVCHttpHandlerProject" name="SomeHandler.axd"/>
</handlers>
My Global.asax.cs was not modified and looks exactly as when it was generated with routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); in RegisterRoutes method.
Still, when I try to get to "http://localhost/Home/SomeHandler.axd", "The resource cannot be found" error occurs. Why? Did I miss something? How should I fix this?
You should be requesting http://localhost/SomeHandler.axd instead of http://localhost/Home/SomeHandler.axd. There's no Home.