You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
Templated Razor Delegates within a @section = '__razor_template_writer': a parameter or local variable cannot have the same name as a method type parameter
#672
Closed
nikoszs opened this issue
Jan 21, 2016
· 2 comments
So the error makes sense, in the section there's already a method parameter called __razor_template_writer when a section is created, and now by creating a templated razor delegate, it tried to create another '__razor_template_write' parameter, hence the error.
I then copied the above code to my view just changed the method parameter name from __razor_template_writer to __test in the above function and called @e("this is a test"). It works.
I tested the initial problem code in MVC5 and works fine, so my question is, is this a bug?
It smells like one. And also, is there a way around it?
The text was updated successfully, but these errors were encountered:
@alzdrak I suspect __razor_template_writer will be used as a lambda parameter for both the section (@section test { ... }) and the template (@<span>@item</span>). Further the two lambdas should nest in the generated code. Could you check the @section code and its relation to the block you pasted above to confirm? Uploading the whole file or placing it in a gist may help as well.
Anything that avoids templates w/in a section (such as your @e("this is a test")) should work around the issue.
I'm having problems creating templated razor delegates within a section of a page.
_Layout.chtml
_SubLayout.cshtml
Which gives me this error:
CS0412 '__razor_template_writer': a parameter or local variable cannot have the same name as a method type parameter
So I went to look at what gets generated, and this is it
So the error makes sense, in the section there's already a method parameter called __razor_template_writer when a section is created, and now by creating a templated razor delegate, it tried to create another '__razor_template_write' parameter, hence the error.
I then copied the above code to my view just changed the method parameter name from
__razor_template_writer
to__test
in the above function and called@e("this is a test")
. It works.I tested the initial problem code in MVC5 and works fine, so my question is, is this a bug?
It smells like one. And also, is there a way around it?
The text was updated successfully, but these errors were encountered: