Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state

For me, the solution (workaround) is to turn off JavaScript debugging on Chrome, which I believe is a new feature introduced in VS 2017. Go to Tools > Options > Debugging > General and turn off the setting for Enable JavaScript Debugging for ASP.NET (Chrome and IE). This is a known issue already, and seems … Read more

How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?

If you open the .aspx file and switch between design view and html view and back it will prompt VS to check the controls and add any that are missing to the designer file. In VS2013-15 there is a Convert to Web Application command under the Project menu. Prior to VS2013 this option was available … Read more

IIS AppPoolIdentity and file system write access permissions

The ApplicationPoolIdentity is assigned membership of the Users group as well as the IIS_IUSRS group. On first glance this may look somewhat worrying, however the Users group has somewhat limited NTFS rights. For example, if you try and create a folder in the C:\Windows folder then you’ll find that you can’t. The ApplicationPoolIdentity still needs … Read more

Cannot read configuration file due to insufficient permissions

There is no problem with your web.config. Your web site runs under a process. In iis you can define the identity of that process. The identity that your web site’s application pool runs as (Network Services, Local System, etc.), should have permission to access and read web.config file. Update: This updated answer is same as … Read more

Unrecognized attribute ‘targetFramework’. Note that attribute names are case-sensitive

This typically happens when you have an attribute of targetFramework=”4.0″ in the web.config but the App Pool is set to run ASP.NET 2.0. The targetFramework attribute is entirely unrecognized by ASP.NET 2.0 – so changing it to 2.0 won’t have the desired effect. Contact Support / Your Administrator and have the AppPool switched to 4.0. … Read more

Stop Visual Studio from launching a new browser window when starting debug?

Open your startup project’s properties (Project → {ProjectName} Properties… from the main menu or right click your project in the Solution Explorer and choose Properties), then navigate to the Web tab and under Start Action choose Don’t open a page. Wait for a request from an external application. You will still be able to use … Read more

Server.MapPath(“.”), Server.MapPath(“~”), Server.MapPath(@”\”), Server.MapPath(“/”). What is the difference?

Server.MapPath specifies the relative or virtual path to map to a physical directory. Server.MapPath(“.”)1 returns the current physical directory of the file (e.g. aspx) being executed Server.MapPath(“..”) returns the parent directory Server.MapPath(“~”) returns the physical path to the root of the application Server.MapPath(“https://stackoverflow.com/”) returns the physical path to the root of the domain name (is … Read more

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

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

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