Question

Has anyone else encountered this in VS 2013? Any way of fixing?

  1. Create a new asp.net web application with visual studio 2013.

  2. Under "Add folders and core references for:", check MVC. Click OK.

  3. Open the web.config and copy the contents.

  4. Add a new text template to your project called "Web.tt"

  5. Paste in the contents of your web.config and change the output extension to be .config. all you need is this line (and then your web.config contents after it): <#@ output extension=".config" #>

  6. Make sure there is no whitespace between the output extension line and the first line of your pasted web.config.

  7. Delete the web.config (including release and debug build targets) so that web.tt is all you have for web.config.

  8. Right click on Web.tt and run custom tool. Make sure web.config is created and now part of your project.

  9. Right click on Controllers folder and select Add -> Controller...

  10. Select MVC 5 Controller - Empty and Click Add.

  11. Name your controller and click Add.

Results:

Error There was an error running the selected code generator: ' Value does not fall within the expected range.'

No correct solution

OTHER TIPS

Microsoft got back to me and they said this is by design...

Resolution

Web.config cannot be deleted to add controller as it is by design. Visual Studio will collapse if web.config is modified underneath.

Workaround:

Config files can include other config files.Web.config include a extensions.config and make an extensions.tt that just generates extensions.config.

Reference : Can a web.config read from an external xml file?

With your consent I am going ahead and closing the case. Please feel free to get back to me if you have any follow-up questions.

Thank you for choosing Microsoft!

It happen to me because i exclusive web.config out of my project.

Just include web.config back and everything ok.

I believe this is a bug in Visual Studio with MVC5. To work around it, instead of generating the web.config from a T4 template, we ended up using XML transformations for each build environment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top