07-22-2023, 09:43 PM
Is it possible to display a view from another controller?
Say for example I have a `CategoriesController` and a `Category/NotFound.aspx` view. While in the `CategoriesController`, I can easly return `View("NotFound")`.
Now say I have a `ProductsController` and an action and view to add a product. However, this action requires that we have a Category to add the Product to. For example, `Products/Add/?catid=10`.
If I am not able to find the Category based on `catid`, I want to show the `NotFound` view from the Categories controller instead of creating a `CategoryNotFound` view under the Products controller.
Is this possible or am I structuring things in the wrong way? Is there a good way to do this?
Say for example I have a `CategoriesController` and a `Category/NotFound.aspx` view. While in the `CategoriesController`, I can easly return `View("NotFound")`.
Now say I have a `ProductsController` and an action and view to add a product. However, this action requires that we have a Category to add the Product to. For example, `Products/Add/?catid=10`.
If I am not able to find the Category based on `catid`, I want to show the `NotFound` view from the Categories controller instead of creating a `CategoryNotFound` view under the Products controller.
Is this possible or am I structuring things in the wrong way? Is there a good way to do this?