frontend-razor-accessors

Generate type-safe Razor routing and ViewData accessors to replace magic strings.

20|3|Updated Aug 13, 2023
One-click install
npx skills add https://github.com/duranserkan/DRN-Project --skill frontend-razor-accessors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-razor-accessors
Source: https://github.com/duranserkan/DRN-Project/tree/main/.agent/skills/frontend-razor-accessors
Command: npx skills add https://github.com/duranserkan/DRN-Project --skill frontend-razor-accessors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Razor views often rely on strings for routing, feature flags, and ViewData keys, which leads to fragile code and refactor risks. This Skill provides a type-safe static accessor pattern to centralize navigation, permissions, and constants, reducing magic strings and easing maintenance.

Core Features & Use Cases

  • Type-safe Get class that hosts routing helpers (Get.Page, Get.Endpoint), permission checks (Get.Claim), and ViewData keys (Get.ViewDataKeys). This pattern improves refactor safety and discoverability in Razor projects.
  • Helper collections group accessors logically (Page and Endpoint collections) to keep routing and constants organized by feature areas.
  • Practical use cases include building navigation links and endpoint calls in Razor views without string literals, and enforcing permission checks in views.

Quick Start

Integrate the central Get class in your Hosted project and begin using Get.Page, Get.Endpoint, Get.Claim, and Get.ViewDataKeys in Razor views.

Frequently Asked Questions about frontend-razor-accessors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate magic strings for routing and ViewData in Razor Views?

Centralize navigation and constants by implementing a static Get class with Page, Endpoint, Claim, and ViewDataKeys collections to replace fragile string literals with type-safe accessors.

How do I organize type-safe routing helpers for .NET Razor Pages?

Group type-safe routing accessors into Page and Endpoint collections within a central Get class to keep navigation, endpoint references, and constants logically organized by feature areas across your project.

Can I enforce permission checks directly inside Razor views without string literals?

Yes, you can enforce permission checks in Razor views without string literals by applying the Get.Claim accessor from the centralized static Get class pattern to manage permissions safely.

What is the best way to centralize navigation links in ASP.NET Razor projects?

The best way to centralize navigation links is using a type-safe static accessor pattern that provides Get.Page and Get.Endpoint helpers, allowing you to build links without relying on fragile string literals.

Why should I use type-safe accessors for ViewData keys in Razor?

Type-safe accessors for ViewData keys reduce refactor risks and improve discoverability by replacing untyped string keys with centralized Get.ViewDataKeys utilities, preventing runtime errors from typos.