Resolution With HttpRequestScoped In Autofac?

Apr 20, 2010

I'm trying to resolve the AccountController in my application, but it seems that I have a lifetime scoping issue.

builder.Register(c => new MyDataContext(connectionString)).As<IDatabase>().HttpRequestScoped();
builder.Register(c => new UnitOfWork(c.Resolve<IDatabase>())).As<IUnitOfWork>().HttpRequestScoped();
builder.Register(c => new AccountService(c.Resolve<IDatabase>())).As<IAccountService>().InstancePerLifetimeScope();
builder.Register(c => new AccountController(c.Resolve<IAccountService>())).InstancePerDependency();

I need MyDataContext and UnitOfWork to be scoped at the HttpRequestLevel.When I try to resolve the AccountController, I get the following error:No scope matching the expression 'value(Autofac.Builder.RegistrationBuilder`3+<>c__DisplayClass0[...]).lifetimeScopeTag.Equals(scope.Tag)' is visible from the scope in which the instance was requested.

View 2 Replies


Similar Messages:

AutoFac And MVC IControllerActivator Needing Container?

Mar 13, 2011

I'm in an interesting situation; I need to pass the IContainer to the IControllerActivator component that I'm defining, yet the IControllerActivator needs to be registered inside of the container. This is because the IControllerActivator will use the container to build the controllers.

I stored the container as a static reference from within the global.asax file; this way, any dependant object (like my activator) on the container can reference it. Since the activator uses the container, and needs to be registered in an autofac module, is there a way to define that this specific mapping needs a reference to the container, or can I register this after the container is built?

View 1 Replies

Using Autofac For DI Into WCF Service Hosted In Web Application?

Jul 28, 2010

I'm having trouble injecting services dependencies into my WCF service using Autofac 1.4.5. I've read and followed the Autofac wiki page on WcfIntegration but my debugging shows me that my WCF service is created by the System.ServiceModel.Dispatcher.InstanceBehavior.GetInstance() method and not by the AutofacWebServiceHostFactory. What am I doing wrong?

I've set up my ajax.svc file to look like the one in the example for use with WebHttpBinding:

<%@ ServiceHost Language="C#" Debug="true"
Service="Generic.Frontend.Web.Ajax, Generic.Frontend.Web"
Factory="Autofac.Integration.Wcf.AutofacWebServiceHostFactory,
Autofac.Integration.Wcf" %>

My WCF service class Ajax is defined like this:

namespace Generic.Frontend.Web
{
[ServiceContract]
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Ajax
{
public MapWebService MapWebService { get; set;}.....

The service already works fine but I can't get the Autofac bits (read: creation/injection) to work.

Removing the default constructor unfortunately leads to the following exception:

System.InvalidOperationException: The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.

View 3 Replies

How To Set The Resolution Of A Webpage Created

Sep 6, 2010

how can we set the resolution of a web page created in asp.net?

View 6 Replies

Constant Screen Resolution For All?

Mar 17, 2011

How would one create a website that would look the same at any resolution? I've heard of making so it will fit for a 800x600 screen but then that just screws everyone that has a higher screen resolution. I've heard about using widths that use percentages and using iframes and things like that.

What's the best way to have one website fits all resolutions?

View 4 Replies

Javascript - Web Page Fit To Resolution?

Feb 24, 2011

I built a new .Net website which will fit nicely on 1200px width resolution.The problem is that some of my users will browse this website with 1024px width.Is there a way to fix this problem quick without changing all the design of the page? For example, to put some javascript that will do the trick.Please keep in mind that the top banner of my site is 1200px wide, and I don't need to support less then 1024px resolution.

View 3 Replies

Web Forms :: How To Get Image Resolution

Apr 7, 2010

I'm working for a graphical company and I'm making a webapplication at the moment. In this application, users can upload images. Before I let them upload an image, I want to check the resolution of it (dpi = min. 300dpi). How can I do this?

View 7 Replies

C# - Resolution Will Change From Different Displays So It Can't Be A Set Value?

Mar 15, 2011

On windows server 2008 can I have a web service or something I can query from a C# application as to the display properties (resolution (height & width)). The C# application does not run on the server so I cannot just detect it from the application itself.ddition to help explain why:I will have a user named "display" and that will be logged on displaying a website (on the server) and I want to be able to check the display from the desktop application so the user knows what resolution to design a template for. The resolution will change from different displays so it can't be a set value

View 2 Replies

Get Resolution And Size Of Image?

Jan 7, 2010

how can i get image info(resolution, size, etc..) of an image that i have upload with asp .net?

View 2 Replies

How To Get The Screen Resolution Of Android Devices In C#

Oct 20, 2010

I'm creating a optimized web page for mobile devices with C#. Is there a way to offer a page for larger screens and one for smaller screens on android devices? With Apple i can differentiate between iPad and iPhone, but how can I do this with the galaxy tab or a regular android phone?I don't want to use any javascript in this case.

View 3 Replies

How To Get Current Screen Resolution Value In Code Behind

Feb 5, 2010

How to get current screen resolution value in code behind for web applications(C#.Net)

View 2 Replies

Web Forms :: Resolution - Set Page To Fit 1024 X 768?

Mar 9, 2010

How to set my page to fit 1024*768 ?. Eventhough i set the width in child control the should override.

View 2 Replies

C# - Type Resolution Error During Precompilation?

Feb 16, 2011

During ASP.NET precompilation of our .NET 3.5 web application, various initialization is performed in type initializers. One of the type initializers throws a custom exception when the environment is incorrectly configured. However, when our custom exception is thrown, here is what the aspnet_compiler.exe tells us:

[exec] error ASPRUNTIME: Type is not resolved for member 'App.Project.CustomException,App.Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
[exec]
[exec] [SerializationException]: Type is not resolved for member 'App.Project.CustomException,App.Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
[exec] at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback)
[exec] at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
[exec] at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
[exec] at System.Web.Compilation.Precompiler.Main(String[] args)

Notice that no "real" stack trace information is included. However, when I change our code to throw an InvalidOperationException (instead of our custom exception), the stack trace is included correctly. (As an aside, our CustomException type is annotated with [Serializable]. When we remove the [Serializable] annotation, the aspnet_compiler.exe complains differently -- that our custom exception is not marked as such.) Does anyone know why throwing a custom exception during ASP.NET precompilation is causing the secondary SerializationException? Why is it trying to serialize the exception? Similarly, why does using a BCL InvalidOperationException not cause the secondary SerializationException?

Could this be because the aspnet_compiler.exe is trying to do some sort of reflection on unexpected exceptions? (And therefore since it does not have our App.Project assembly loaded, it is unable to resolve the type?)

View 1 Replies

Web Forms :: How To Display Resolution In Java Little

Mar 13, 2011

there I do check resolution code below.and i like to change my form.style depense resolution how to do it? thnaks for help

<form id="form1" runat="server"
style="background-image: url('Images/picture1280x1024.jpg')">
<script type = "text/javascript" language="javascript">
var width = screen.width;
[code]...

View 1 Replies

Web Forms :: Height In Percentage And All Resolution Without Scroll?

Jan 26, 2011

simple html page height in percentage + all resolution not working. I tried removing the height and giving in % but it does not w

[Code]....

View 15 Replies

System.MissingMemberException: Overload Resolution Failed

Sep 7, 2010

I have justed tried to configure the PHP on my web server following the article (http://www.iis-aid.com/articles/how_to_guides/installing_php_5_iis_5_simple_steps?page=0%2C0) and php now runs fine without any problem but it have affected by asp.net web applications.I am receiveing the following error on the server, so I undone all the changes for php and restarted the server

View 5 Replies

Javascript - How To Get Client Details In .NET Ie. Browser, Resolution And OS

May 24, 2010

I need to get client stats for browser (not full long description but short names, generally firefox,ie6,ie7,ie8,safari,chrome,opera and mozilla). Client resolution and OS ie. Windows Vista, Ubuntu .

View 1 Replies

Html - How To Develop A Resolution Independent Website

Mar 3, 2011

how to write htm code as a result my website will be resolution independent and it will show same in any resolution and any pc monitor size.

View 4 Replies

Web Forms :: Page Detect The Resolution Of The Screen Then Run

Mar 30, 2010

I designed my page (Using ASP .net C#) in 1024*768. if resolution of the screen decresed(ex 800*600) then vertical and horizental scroll bar appear. And if resolution of the screen incresed then right side of the screen is become blank. i want whatever the screen resolution is there my page is run fine after detecting the resolution of the screen and then run.

View 4 Replies

Overload Resolution Failed Because No Accessible DrawImage?

Feb 2, 2011

After looking at about 200 examples on this and other sides, I combined several pieces of code that I found and created one to upload an image, give it a random name, verify that a file with that same names doesn't already exists on the server, resize the image 3 different ways; one keeping aspect ratio and two square thumbnails; and save them to different folders in the server. This is the code:

[Code]....

I'm getting an error on line 95 and 112:

MediumGraphic.DrawImage(Original_Image, MediumRectangle, xm, ym, am, am, GraphicsUnit.Pixel)

I get the error on intellisense: Overload resolution failed because no accessible DrawImage can be called without a narrowing conversion. ..... Argument matching parameter 'srcX' narrows from 'Double' to Inter... narrows from 'Double' to 'Single'.

View 5 Replies

Web Forms :: Html Page Get Disturbs When Resolution Changes?

Jan 15, 2010

i have an aspx page that contains 4 divs and some content is in there.it works fyn for my resolution on which it is created but the page content gets disturbed when the resolution changes.Why is this so and what is the remedy to this problem?i want the page content to automatically adjust as the resolution changes.

View 5 Replies

Web Forms :: How To Change Resolution Of Image After Upload

Jan 9, 2013

I want to change resolution of image in asp.net ...

View 1 Replies

How To Load A Stylesheet Based On The Client's Screen Resolution

Apr 7, 2010

I've been reading a lot of articles containing tips regarding in creating commercial websites and it seems the client's screen resolution is a factor here.

I'm wondering if there is a way in VB.NET to detect the screen resolution that your client is using? I really don't want to use JavaScript here, since the some clients disable the use of JavaScript.

And also, is there a way to load a Stylesheet based on the client's screen resolution? For example...

[code]....

View 5 Replies

Css - Design Webpage View Which Support Multi Resolution?

Nov 26, 2010

I have created my webpage in asp.net in 1024*768 resolution, my problem was that when i change my monitor resolution then the controls in my webpage will be displayed in unmanaged manner. How to arrange items in my webpage which support multiple resolution. Whatever the resolution of my monitor the controls in my webpage will display as it is as managed in 1024*768 reolution.

View 1 Replies

C# - Create Better Quality Higher Resolution Thumbnail Image

Sep 28, 2010

I am looking c# code which creates better quality higher resolution thumbnail image. i am having an image of dimension(600 * 900) and i need to create thumbnail of dimension (100 * 100) with high quality.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved