-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60a3b29
commit 05bf1f5
Showing
3 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace text_counter_razor.Pages; | ||
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
namespace text_counter_razor.Pages | ||
{ | ||
public string? RequestId { get; set; } | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string? RequestId { get; set; } | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace text_counter_razor.Pages; | ||
|
||
public class IndexModel : PageModel | ||
namespace text_counter_razor.Pages | ||
{ | ||
private readonly ILogger<IndexModel> _logger; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
public IndexModel(ILogger<IndexModel> logger) | ||
public class IndexModel : PageModel | ||
{ | ||
_logger = logger; | ||
} | ||
private readonly ILogger<IndexModel> _logger; | ||
|
||
public void OnGet() { } | ||
public IndexModel(ILogger<IndexModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
public class TextCounterModel : PageModel | ||
namespace text_counter_razor.Pages | ||
{ | ||
[BindProperty] | ||
public string? TextContent { get; set; } //text content string input from text box | ||
public int Characters { get; set; } //number of characters | ||
public int Words { get; set; } //number of words | ||
public int Lines { get; set; } //number of lines | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
public void OnPost() | ||
public class TextCounterModel : PageModel | ||
{ | ||
this.TextContent = this.Request.Form["textContent"]; //get text box input | ||
this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text | ||
this.Words = | ||
this.TextContent?.Split( | ||
new char[] { ' ', '\r', '\n' }, | ||
StringSplitOptions.RemoveEmptyEntries | ||
).Length ?? 0; | ||
this.Lines = | ||
this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; | ||
[BindProperty] | ||
public string? TextContent { get; set; } //text content string input from text box | ||
public int Characters { get; set; } //number of characters | ||
public int Words { get; set; } //number of words | ||
public int Lines { get; set; } //number of lines | ||
|
||
public void OnPost() | ||
{ | ||
this.TextContent = this.Request.Form["textContent"]; //get text box input | ||
this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text | ||
this.Words = | ||
this.TextContent?.Split( | ||
new char[] { ' ', '\r', '\n' }, | ||
StringSplitOptions.RemoveEmptyEntries | ||
).Length ?? 0; | ||
this.Lines = | ||
this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; | ||
} | ||
} | ||
} |