Skip to content

Optional parameter defaults in Controller Method are ignored.  #38440

Closed
@eat-sleep-code

Description

@eat-sleep-code

In .NET 5, if no path was specified in the URL after /docs, then "index.html" was assumed and was passed as the path value.

public class StaticContentController : Controller
	{
		[Authorize]
		[HttpGet]
		[ResponseCache(Duration = 3600)]
		[Route("/docs/{**path}")]
		/*  Place HTML contents in /static/docs/ folder. */
		public IActionResult Docs(string path = "index.html")
		{
			return StaticContentExtensions.GetFile(this, path, "/static/docs/");
		}
	}
}

In .NET 6, null is being passed along as the value of path. I would expect that "index.html" should be passed in the path variable as it is set as the default of the optional parameter.

Metadata

Metadata

Assignees

Labels

old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions