本文整理汇总了C#中FormDataCollection.Get方法的典型用法代码示例。如果您正苦于以下问题:C# FormDataCollection.Get方法的具体用法?C# FormDataCollection.Get怎么用?C# FormDataCollection.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormDataCollection
的用法示例。
在下文中一共展示了FormDataCollection.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostLogin
public string PostLogin(FormDataCollection body)
{
string username = body.Get("username");
string password = body.Get("password");
using(var session = store.OpenSession())
{
var profile = session.Load<Profile>("profiles/" + username);
if(profile.Password == password)
{
var defaultPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(new[] {new Claim(MyClaimTypes.ProfileKey, profile.Id)},
"Application" // this is important. if it's null or empty, IsAuthenticated will be false
));
var principal = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.
ClaimsAuthenticationManager.Authenticate(
Request.RequestUri.AbsoluteUri, // this, or any other string can be available
// to your ClaimsAuthenticationManager
defaultPrincipal);
AuthenticationManager.EstablishSession(principal);
return "login ok";
}
return "login failed";
}
}
示例2: AddFiles
private TreeNodeCollection AddFiles(string folder, FormDataCollection queryStrings)
{
var pickerApiController = new FileSystemPickerApiController();
//var str = queryStrings.Get("startfolder");
if (string.IsNullOrWhiteSpace(folder))
return null;
var filter = queryStrings.Get("filter").Split(',').Select(a => a.Trim().EnsureStartsWith(".")).ToArray();
var path = IOHelper.MapPath(folder);
var rootPath = IOHelper.MapPath(queryStrings.Get("startfolder"));
var treeNodeCollection = new TreeNodeCollection();
foreach (FileInfo file in pickerApiController.GetFiles(folder, filter))
{
string nodeTitle = file.Name;
string filePath = file.FullName.Replace(rootPath, "").Replace("\\", "/");
//if (file.Extension.ToLower() == ".gif" || file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".png")
//{
// nodeTitle += "<div><img src=\"/umbraco/backoffice/FileSystemPicker/FileSystemThumbnailApi/GetThumbnail?width=150&imagePath="+ HttpUtility.UrlPathEncode(filePath) +"\" /></div>";
//}
TreeNode treeNode = CreateTreeNode(filePath, path, queryStrings, nodeTitle, "icon-document", false);
treeNodeCollection.Add(treeNode);
}
return treeNodeCollection;
}
示例3: Edit
public string Edit(FormDataCollection form)
{
var retVal = string.Empty;
var operation = form.Get("oper");
var id = form.Get("Id").Split(',')[0].ToInt32();
if (string.IsNullOrEmpty(operation)) return retVal;
PackageFeeEduInfo info;
switch (operation)
{
case "edit":
info = CatalogRepository.GetInfo<PackageFeeEduInfo>(id);
if (info != null)
{
info.Name = form.Get("Name");
CatalogRepository.Update(info);
}
break;
case "add":
info = new PackageFeeEduInfo { Name = form.Get("Name") };
CatalogRepository.Create(info);
break;
case "del":
CatalogRepository.Delete<PackageFeeEduInfo>(id);
break;
}
StoreData.ReloadData<PackageFeeEduInfo>();
return retVal;
}
示例4: AddToCalendar
public IHttpActionResult AddToCalendar(FormDataCollection form)
{
string message = "success";
try
{
CylorDbEntities context = this.getContext();
string ThisDay = form.Get("ThisDay");
string sSelectUserId = form.Get("sSelectUserId");
int nCalendarUserListId;
if (int.TryParse(sSelectUserId, out nCalendarUserListId) && DateFunctions.IsValidDate(ThisDay))
{
CalendarItem instance = new CalendarItem();
instance.CalendarDate = DateTime.Parse(ThisDay);
instance.CalendarUserListId = nCalendarUserListId;
instance.EnteredDate = DateTime.Now.Date;
context.CalendarItems.Add(instance);
context.SaveChanges();
}
}
catch (Exception ex)
{
message = ex.Message;
}
dynamic json = new ExpandoObject();
json.message = message;
return Json(json);
}
示例5: CreateFromUri
public void CreateFromUri()
{
FormDataCollection form = new FormDataCollection(new Uri("http://foo.com/?x=1&y=2"));
Assert.Equal("1", form.Get("x"));
Assert.Equal("2", form.Get("y"));
}
示例6: PostInviteToHousehold
public string PostInviteToHousehold(FormDataCollection form)
{
string user = form.Get("UserId");
string email = form.Get("Email");
return Sql.NonQuery("InvitationSent",
new SqlParameter("email", email),
new SqlParameter("user", user));
}
示例7: PostHouseholdAdd
public IEnumerable<Households> PostHouseholdAdd(FormDataCollection form)
{
string name = form.Get("Name");
string house = form.Get("HouseholdId");
return db.Database.SqlQuery<Households>("EXEC AddHousehold @householdId, @name",
new SqlParameter("householdId", house),
new SqlParameter("name", name));
}
示例8: IndexerIsEquivalentToGet
public void IndexerIsEquivalentToGet()
{
FormDataCollection form = new FormDataCollection(new Uri("http://foo.com/?x=1&y=2"));
Assert.Equal("1", form.Get("x"));
Assert.Equal(form["x"], form.Get("x"));
Assert.Equal(form[null], form.Get(null));
}
示例9: CheckDuplicate
public string CheckDuplicate(FormDataCollection form)
{
string mobile1 = form.Get("mobile1");
string mobile2 = form.Get("mobile2");
string tel = form.Get("tel");
string email = form.Get("email");
int duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(mobile1, mobile2, tel, email, string.Empty);
return duplicateId.ToString();
}
示例10: GetImageCount
public IHttpActionResult GetImageCount(FormDataCollection form)
{
string imageGroup = form.Get("imageGroup");
string path = form.Get("path");
var mappedPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/MouseTrailerPics/" + path + "/");
List<string> directoryFiles = new List<string>(Directory.GetFiles(mappedPath, "*" + imageGroup + "*"));
return Json(directoryFiles.Count);
}
示例11: CreateFromPairs
public void CreateFromPairs()
{
Dictionary<string, string> pairs = new Dictionary<string,string>
{
{ "x", "1"},
{ "y" , "2"}
};
var form = new FormDataCollection(pairs);
Assert.Equal("1", form.Get("x"));
Assert.Equal("2", form.Get("y"));
}
示例12: GetTreeNodes
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
if (!string.IsNullOrWhiteSpace(queryStrings.Get("startfolder")))
{
string folder = id == "-1" ? queryStrings.Get("startfolder") : id;
folder = folder.EnsureStartsWith("/");
TreeNodeCollection tempTree = AddFolders(folder, queryStrings);
tempTree.AddRange(AddFiles(folder, queryStrings));
return tempTree;
}
return AddFolders(id == "-1" ? "" : id, queryStrings);
}
示例13: CalcDistance
public double CalcDistance(FormDataCollection data)
{
int x1 = int.Parse(data.Get("x1"));
int y1 = int.Parse(data.Get("y1"));
int x2 = int.Parse(data.Get("x2"));
int y2 = int.Parse(data.Get("y2"));
Point startPoint = new Point { X = x1, Y = y1 };
Point endPoint = new Point { X = x2, Y = y2 };
return Math.Sqrt(
Math.Pow(endPoint.X - startPoint.X, 2) +
Math.Pow(endPoint.Y - startPoint.Y, 2));
}
示例14: Post
// POST api/<controller>
public HttpResponseMessage Post(FormDataCollection form)
{
var command = new InboundMail();
command.Sender = form.Get("sender");
command.Body = form.Get("body-plain");
command.Stripped = form.Get("stripped-text");
string token;
using (var db = new UsersContext())
{
var user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == command.Sender.ToLower());
if (user == null)
return Request.CreateResponse(HttpStatusCode.BadRequest);
if (user.BasecampCredentials == null || string.IsNullOrWhiteSpace(user.BasecampCredentials.AccessToken))
return Request.CreateResponse(HttpStatusCode.BadRequest);
token = user.BasecampCredentials.AccessToken;
}
var basecamp = new BasecampClient();
var lookfor = "I will complete";
var rx = new Regex(@"(\S.+?[.!?])(?=\s+|$)");
foreach (Match match in rx.Matches(command.Body))
{
var index = match.Value.IndexOf(lookfor);
if (index >= 0)
{
var msg = match.Value.Replace(lookfor, "Complete");
var notice = "task created ok";
try
{
basecamp.CreateTask(msg, token);
}
catch (System.Exception e)
{
notice = e.ToString();
}
// SendSimpleMessage(command.Sender, notice);
break;
}
}
return Request.CreateResponse(HttpStatusCode.Accepted);
}
示例15: Edit
public string Edit(FormDataCollection form)
{
var retVal = string.Empty;
var operation = form.Get("oper");
var id = ConvertHelper.ToInt32(form.Get("Id").Split(',')[0]);
WebServiceConfigInfo info;
switch (operation)
{
case "edit":
info = WebServiceConfigRepository.GetInfo(id);
if (info != null)
{
info.Value = form.Get("Value");
info.Type = form.Get("Type").ToInt32();
info.BranchId = form.Get("BranchId").ToInt32();
WebServiceConfigRepository.Update(info);
}
break;
case "add":
info = new WebServiceConfigInfo
{
Value = form.Get("Value"),
Type = form.Get("Type").ToInt32(),
BranchId = form.Get("BranchId").ToInt32(),
};
WebServiceConfigRepository.Create(info);
break;
case "del":
WebServiceConfigRepository.Delete(id);
break;
}
StoreData.ListWebServiceConfig = WebServiceConfigRepository.GetAll();
return retVal;
}