ASP.NET MVC 5 Cannot Add Controller - asp.net

all,
Just wanted to add to the body of knowledge. I was confounded, trying many solutions, when I couldn't add a controller to just one MVC project. I was getting the error:
There was an error running the selected code generator:
'The parameter is incorrect [...] '
Answer below...

It turned out to be very obvious, but since it wasted my time, here you go:
I had saved my web.config file using Save as... to another location as a backup before making changes. The project was tracking the saved copy instead of the one in the project. It looked the same in the Solution Explorer, of course. Remove, add existing, et voila.

I solved this by Excluding the Web.Config from the project and then Including it in the project

It's a simple close your web.config file(or any system file) and try again. It will work.

Related

ASP web.config exclude bin folder on publishing

It is my first experience with asp.net. I have some large dll in my bin that never change and I would like to exclude them from publishing every time I make small changes to the pages. I know I need to add a section in my web.config but I do not know where and what to write in it to exclude the bin folder.
I already looked at few similar question on SO but none of them are really giving a clear answer to my need.
This is my web.config in which I have already added successfully the connection string for the production server and the error mode to have some feedback about errors during deployement phase.
Few lines of code to direct me on what to change will be appreciated.
To exclude any file from being copied; you can control this behavior by adding that file to your project; Once you add that file, you will see it in your Solution Explorer Right click on file and choose Properties . On the property page there is a Property called 'Copy to Output Directory' use that.

Web.config replacement, missing section

I've spent a day on this 'simple' problem...
I'm using Web Deployment Projects to deploy my MVC3 webapp. I tell it to replace the appSettings section with one in a config file by entering
appSettings=Config\AppSettings.Production.config;
That works perfectly. The resulting (deployed) Web.config file has been correctly transformed and now contains the production settings I told it to use.
But, trying to do the same thing with a custom section 'spring' using exactly the same method
spring=Config\Spring.Production.config;
...I get...
web.config(1): error WDP00002: missing section spring
The spring section is at exactly the same level as the appSettings element, so I don't know why it doesn't work.
There are loads of other people with the same problem, but no satisfactory answers that I can find.
The correct syntax to reference external file is like this:
<spring configSource="Config\Spring.Production.config" />
The file="Config\AppSettings.Production.config" syntax that works with appSettings section won't work with custom sections as far as I remember, as they don't implement such property.

Convert to web application error - could not parse aspx file

I occasionally get errors in my aspx files which are caused by problems with the designer file. When this happens I delete the designer file, right click on the aspx file and select "Convert to Web Application".
Usually regenerating the designer file works perfectly, however sometimes I get an error which simply says "Could not parse the file pathToFile.aspx". When this happens there are no useful errors displayed in the error panel which would indicate what the problem is.
I got this error a little while ago, did some searching and found a blog which explains how to get round this problem. It suggests closing the file, cleaning the project, rebuilding then tring again. VS should now give you a more useful error message which pinpoints the problem. This has worked for me in the past, but doesn't work all the time.
Has anyone found a better way of identifying the problem in the aspx file when the "Could not parse file" error is displayed?
I've still not managed to find out why this problem is occurring. VS just seems to be tying itself in knots. However I have found another solution which works when the solution mentioned in my question does not. Simply copy the aspx and code behind into notepad, delete the files from your project, recreated them and copy the code back in. Why does this work? I have no idea
This call is old, but here is a solution if someone else finds this. I had the same problem migrating an AspX app from VS2008 to VS2015. Not all the files migrated. Make sure ALL files have namespaces, and that the name space is references correctly in the aspx file.
Right click on the project select unload project
In windows explorer, create a new file for every file that did not migrate, my example MyForm.aspx, call this file MyForm.aspx.designer.cs
The file must contain the following:
namespace MyProject.pages
{
public partial class MyForm
{
}
}
Save the file and edit the project file (MyProject.csproj) find the entry for your form
<Compile Include="pages\MyForm.aspx.cs">
<DependentUpon>MyForm.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
And under it link the new design file:
<Compile Include="pages\MyForm.aspx.designer.cs">
<DependentUpon>MyForm.aspx</DependentUpon>
</Compile>
Do this for all the files that would not convert. Once completed reload the project and for each file open the markup, add a space, and save. VS will parse the file and store the contents in the designer.

Error Connecting to Undo Manager of Source File XYZ

I've been getting an error recently while debugging an ASP.NET application in Visual Studio 2008:
'Error connecting to undo manager of source file XYZ'
Any idea how I can get rid of the error?
Even simpler:
My experiment consisted of simply opening the designer.cs file, typing a character somewhere in the file, deleting the new character, saving the file and recompiling.
Found on That One Developer Blog and it worked perfectly for me.
Wouldn't you know it; just after I post this I find a workaround in Scott Hanselman's Blog, in the comments:
1) Right-click the designer file and select delete
2) Right-click the aspx file and select Convert to Web Application
Thanks to Matthew, whomever you are.
I have face the same problem. And I solved it by exclude this file from project and rebuild solution. Then include this file again...DONE!
GOOD LUCK!
I faced the same error now. I had to just open the designer file while editing the aspx file and once done, save both. You don't even have to type any text in the designer. That did the trick!
this one has worked for me:--
"Open desiner.cs file Type some text in it Delete the text you have typed. Save and build the application"
Thanks a lot Jitendra Kumar!!
Open desiner.cs file
Type some text in it
Delete the text you have typed.
Save and build the application.
*** I know this is an old question, and already answered but i'am adding my answer , hopefully it would help someone
In my case the referred file was .cs class, and since there is no .desiner.cs file, i needed another solution
so the solution for my case was to navigate tho the solution folder in windows explorer and delete the .suo file , reopen the solution and rebuild
Closing the solution and deleting the Temporary ASP.Net files directory fixed this for me. [link]
I got this error when i double clicked an asp.net button by mistake and removed it afterwords in the aspx file and .cs file but not in the Designer.cs file. Make sure all the three got files got updated.

How to force my ASP.net 2.0 app to recompile

I have a ASP.net 2.0 app and I have made some changes the the source file ( cs files ). I uploaded the changes with the belief that it would auto-recompile. I also have the compiled dll in MY_APP/bin. I checked it and noticed that it did not recompile. Please understand I am new to this.
my #1 way to do this, add white space to the top of the web config file, after the xml declaration tag.
It forces the node to re-cache and recompile. We even have a page deep in the admin called Flush.aspx that does it for us.
I use a similar method to ChanChan, but instead of whitespace I put a comment in the web.config to indicate when/why the config was edited.
It's always best to just actually run a build after making .cs changes.
Where are you running it? Is this for debugging or production?
In VS menu you have Build -> Rebuild Solution

Resources