本文整理汇总了C#中System.Web.HttpRequestBase.Unvalidated方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestBase.Unvalidated方法的具体用法?C# HttpRequestBase.Unvalidated怎么用?C# HttpRequestBase.Unvalidated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpRequestBase
的用法示例。
在下文中一共展示了HttpRequestBase.Unvalidated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SavePost
public int SavePost(HttpRequestBase Request, ModelStateDictionary ms)
{
int postId, userId;
string Title = Request.Unvalidated("Title"),
Content = Request.Unvalidated("Content");
int.TryParse(Request.Unvalidated().Form["id"], out postId);
int.TryParse(Request.Unvalidated().Form["UserId"], out userId);
if(string.IsNullOrWhiteSpace(Title))
ms.AddError("Title", "Title cannot be empty!");
if(Title.Length > 100)
ms.AddError("Title", "Title is too long!");
if(string.IsNullOrWhiteSpace(Content))
ms.AddError("Content", "You have to post something!");
if(!ms.IsValid)
return 0;
// tiny_mce bug?
Content = Content.Replace("<p> </p>", "");
if(postId <= 0) {
// Insert
string Slug = string.Empty;
foreach(var c in Title)
if(char.IsLetterOrDigit(c))
Slug += c;
else if(char.IsWhiteSpace(c))
Slug += "-";
db.Execute("INSERT INTO Posts (UserId, Published, Title, Content, Slug) VALUES (@0, @1, @2, @3, @4)", userId, DateTime.Now, Title, Content, Slug);
postId = (int)db.GetLastInsertId();
} else {
// Update
db.Execute("UPDATE Posts SET [email protected], [email protected], [email protected] WHERE [email protected]", Title, Content, DateTime.Now, postId);
}
return postId;
}
示例2: GetQueryStringValue
private static string GetQueryStringValue(HttpRequestBase request, string key)
{
return request.Unvalidated().Form[key] ?? request.QueryString[key];
}