Structr
  • Welcome
  • Utilities
    • Abstractions
      • Check
      • Ensure
      • Money
      • HierarchyId
      • Providers
        • SequentialGuidProvider
      • Extensions
        • DateTime
        • Dictionary
        • DirectoryInfo
        • Enumerable
        • Enum
        • Expression
        • Int
        • Long
        • MemberInfo
        • Object
        • Queryable
        • ServiceCollection
        • String
        • Type
      • Helpers
        • AsyncHelper
        • BindHelper
      • JsonConverters
        • DateOnly
        • TimeOnly
        • StringNumber
    • Collections
      • AutoMapper extensions
    • IO
      • FileHelper
      • MimeTypeHelper
      • PathHelper
      • SequentialFileName
    • Configuration
      • Providers
        • JSON-file
        • XML-file
        • In-Memory
        • Consul
      • Get settings
      • Set settings
      • Customization
    • Email
      • Razor
    • Navigation
      • Menu
      • Breadcrumbs
    • Security
  • Domain
    • Domain
      • Entities
      • Value objects
  • Data Access
    • Entity Framework Core
    • Entity Framework 6
  • Use Cases
    • Operations
      • Filtering
      • Decoration
    • Notices
    • Validation
    • Specifications
    • Stateflows
      • StateMachine
      • Configurations
  • Presentation
    • ASP.NET Core
      • Client
      • Http
      • JavaScript
      • Json
      • Mvc
      • Referrer
      • Rewrite
      • Routing
      • TagHelpers
      • Validation
Powered by GitBook
On this page
  • Controller extensions
  • HttpRequest extensions
  • ReferrerTagHelper

Was this helpful?

Edit on GitHub
  1. Presentation
  2. ASP.NET Core

Referrer

This part contains tools for working with HTTP referrer and other related things. Typical use-case of such tools is, for example, specifying of redirect back to entity's details form from edit form is needed after pressing "Ok" button or "Cancel" button.

Controller extensions

Method name
Return type
Description

RedirectToReferrer

RedirectResult

Creates RedirectResult object specifying redirect to url depending on presence __Referrer key (specified in ReferrerConstants.Key) in HttpRequest.Form. In case of existing of such key the corresponding url from From value will be used to redirect to. In other case the provided url parameter will be used.

HttpRequest extensions

Method name
Return type
Description

GetReferrer

string

Gets a string containing url gotten from HttpRequest.Form with __Referrer key. If there are no such key then the specified url will be returned instead.

ReferrerTagHelper

An TagHelper implementation adding referrer link to page. It could be helpful when, for example, redirect back to entity's details form from edit form is needed after pressing "Ok" button or "Cancel" button.

<a asp-referrer="@referrerAddress" class="btn btn-link btn-cancel">Cancel</a>

This will be (depending on context and app structure) rendered into something like:

<a class="btn btn-link btn-cancel" href="/admin/users/7">Cancel</a>
<input name="__Referrer" type="hidden" value="/admin/users/7"/>
PreviousMvcNextRewrite

Last updated 2 years ago

Was this helpful?