Skip to content

dealing with Web API and MVC in the same service #196

@zijianhuang

Description

@zijianhuang

Solution 1:

Wildcard of controller exclusion.

Solution 2:

Check ApiController when enumerating controllers.

Solution 1 is likely enough, unless there are a lot real world cases demanding solution 2.

  1. MyBusiness.Domain.Mvc* will be excluded
		string[] excludedControllerNames;
		/// <summary>
		/// Filters to exclude some controllers. For example, [My.Namespace.Home, My.Namespace.FileUpload] for My.Namespace.HomeController and My.Namespace.FileUploadController.
		/// Wildcard "My.Mvc*" will filter out "My.Mvc.Home" and "My.MvcSomething".
		/// </summary>
		public string[] ExcludedControllerNames
		{
			get { return excludedControllerNames; }
			set
			{
				excludedControllerNames = value;
				var candidates = excludedControllerNames.Where(d=> d.EndsWith('*')).ToArray();
				if (candidates.Length > 0)
				{
					excludedWildCard = candidates.Select(d => d.TrimEnd('*')).ToArray();
				}
			}
		}

		string[] excludedWildCard;

implemented. Until next release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions