Can an ASP.NET MVC controller return an Image?

Use the base controllers File method. public ActionResult Image(string id) { var dir = Server.MapPath(“/Images”); var path = Path.Combine(dir, id + “.jpg”); //validate the path for security or use other means to generate the path. return base.File(path, “image/jpeg”); } As a note, this seems to be fairly efficient. I did a test where I requested … Read more

jQuery $(document).ready and UpdatePanels?

An UpdatePanel completely replaces the contents of the update panel on an update. This means that those events you subscribed to are no longer subscribed because there are new elements in that update panel. What I’ve done to work around this is re-subscribe to the events I need after every update. I use $(document).ready() for … Read more

WCF – How to Increase Message Size Quota

You’ll want something like this to increase the message size quotas, in the App.config or Web.config file: <bindings> <basicHttpBinding> <binding name=”basicHttp” allowCookies=”true” maxReceivedMessageSize=”20000000″ maxBufferSize=”20000000″ maxBufferPoolSize=”20000000″> <readerQuotas maxDepth=”32″ maxArrayLength=”200000000″ maxStringContentLength=”200000000″/> </binding> </basicHttpBinding> </bindings> And use the binding name in your endpoint configuration e.g. … bindingConfiguration=”basicHttp” … The justification for the values is simple, they are sufficiently … Read more

What is the difference between ‘classic’ and ‘integrated’ pipeline mode in IIS7?

Classic mode (the only mode in IIS6 and below) is a mode where IIS only works with ISAPI extensions and ISAPI filters directly. In fact, in this mode, ASP.NET is just an ISAPI extension (aspnet_isapi.dll) and an ISAPI filter (aspnet_filter.dll). IIS just treats ASP.NET as an external plugin implemented in ISAPI and works with it … Read more

How to enable external request in IIS Express?

There’s a blog post up on the IIS team site now explaining how to enable remote connections on IIS Express. Here is the pertinent part of that post summarized: On Vista and Win7, run the following command from an administrative prompt: netsh http add urlacl url=http://vaidesg:8080/ user=everyone For XP, first install Windows XP Service Pack … Read more

Compile Views in ASP.NET MVC

From the readme word doc for RC1 (not indexed by google) ASP.NET Compiler Post-Build Step Currently, errors within a view file are not detected until run time. To let you detect these errors at compile time, ASP.NET MVC projects now include an MvcBuildViews property, which is disabled by default. To enable this property, open the … Read more

Unable to update the EntitySet – because it has a DefiningQuery and no element exist

It usually happens because one of the following reasons: Entity Set is mapped from Database view A custom Database query Database table doesn’t have a primary key After doing so, you may still need to update in the Entity Framework designer (or alternatively delete the entity and then add it) before you stop getting the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)