查看:Registration.cshtml
@model MyNameSpace.Models.NewPatientRegistrationViewModel
<div> ... All the HTML </div>
Run Code Online (Sandbox Code Playgroud)
型号:AccountViewModels.cs
namespace MyNameSpace.Models
{
public class RegistrationViewModel
{
[Display(Name = "Date of Birth")]
public string DOB { get; set; }
public int DOBYear { get; set; }
public int DOBMonth { get; set; }
public int DOBDay { get; set; }
public NewPatientRegistrationViewModel() { }
}
}
Run Code Online (Sandbox Code Playgroud)
控制器:AccountControllers.cs
public ActionResult Registration()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
在视图中,对@Model的引用为null,并引发null异常错误。还是MVC的新手...我确定我缺少明显的东西。
我在网上寻找一个简单的小加密方法,它会接受一个字符串,加密它,然后解密它.我的想法是,我需要一个不能在计划文本中的URL.
我发现的课程大部分时间都很有用,但有时候,我最终会得到一个带有/的加密字符串:
OSprnGR/0os4DQpQsa0gIg==
Run Code Online (Sandbox Code Playgroud)
可以想象,这在URL中使用时会导致问题.所以我认为,如果我只是UrlEncode字符串,它将解决问题.
它没有.
即使URL看起来像这样,我仍然会得到相同的错误:
http://localhost:54471/BrokerDashboard/BuyingLeads/LeadView/OSprnGR%2f0os4DQpQsa0gIg%3d%3d
Run Code Online (Sandbox Code Playgroud)
而不是这个:
http://localhost:54471/BrokerDashboard/BuyingLeads/LeadView/OSprnGR/0os4DQpQsa0gIg==
Run Code Online (Sandbox Code Playgroud)
HTTP错误404.0 - 未找到您要查找的资源已被删除,名称已更改或暂时不可用.
这是我正在使用的课程:
public static class Encryption
{
public static string keyString { get { return "6C3A231C-57B2-4BA0-AFD6-306098234B11"; } }
private static byte[] salt = Encoding.ASCII.GetBytes("somerandomstuff");
public static string Encrypt(string plainText)
{
Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(keyString, salt);
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(new CryptoStream(ms, new RijndaelManaged().CreateEncryptor(key.GetBytes(32), key.GetBytes(16)), CryptoStreamMode.Write));
sw.Write(plainText);
sw.Close();
ms.Close();
string beforeUrlEncoded = Convert.ToBase64String(ms.ToArray());
string afterUrlEndcoded = HttpUtility.UrlEncode(beforeUrlEncoded);
return afterUrlEndcoded;
}
public static string Decrypt(string …
Run Code Online (Sandbox Code Playgroud) 当用户在DOM中执行某些操作时,我需要进行服务器端调用(单击复选框,选择下拉列表等.这是一系列事件:
我遇到的问题是4和5经常被反转,并且在标签更新之前,微调器有时会消失2或3秒.
我正在尝试使用.when()来确保没有发生这种情况,但我似乎没有做得对.我一直在看这个帖子,这个和jquery自己的文档.
这就是我现在所处的位置......
function UpdateCampaign() {
$('#overlay').fadeIn();
$.when(SaveCampaign()).done(function () {
$('#overlay').fadeOut();
});
}
function SaveCampaign() {
var formData =
.... // get some data
$.ajax({
url: '/xxxx/xxxx/SaveCampaign',
type: 'GET',
dataType: 'json',
data: { FormData: formData },
success: function (data) {
var obj = $.parseJSON(data);
.... // update a label, set some hidden inputs, etc.
},
error: function (e) {
console.log(e)
}
});
}
Run Code Online (Sandbox Code Playgroud)
一切正常.执行服务器端方法,返回并解析正确的JSON,并按预期更新标签.
我只需要那个dang微调器等待并淡出,直到标签更新为止.
我正在尝试创建一个非常简单的系统托盘图标,它只是一个带有白色边框的动态彩色圆圈.为此,我们使用Webdings字体.Webdings中的"n"只是一个简单的圆圈.
我目前正在做的几乎就在那里,但是在某些PC上(但不是全部)它最终会在它周围形成一个波涛汹涌的黑色边框:
这是我得到的:
protected static Icon GetTrayIconFromCache(Color statusColor)
{
Bitmap bmp = new Bitmap(16,16);
Graphics circleGraphic = Graphics.FromImage(bmp);
circleGraphic.DrawString("n", new Font("Webdings", 12F, FontStyle.Regular), Brushes.White, -3f, -2f);
circleGraphic.DrawString("n", new Font("Webdings", 9F, FontStyle.Regular), new SolidBrush(statusColor), 0f, -1f);
Icon ico = Icon.FromHandle((bmp).GetHicon());
return ico;
}
Run Code Online (Sandbox Code Playgroud)
无论我尝试什么,我都无法摆脱圆圈外面那些丑陋的黑点.它们没有出现在每个人身上......一些开发人员看不到它,看起来很干净.我们还没有弄清楚那些看起来不错的PC和不合适的PC之间的共性.
但是......有更好的方法吗?
我一直在VS2017中的一个应用程序中非常愉快地工作。调试就好了。突然之间
当我调试并尝试将鼠标悬停在变量上时,我没有看到包含对象详细信息的常规弹出窗口。如果将其放在Watch中,我将得到以下值:
C#编译器中的内部错误
我关闭并重新打开VS,然后重新启动。仍然会出现相同的错误。
那里很少有这件事。有人看过吗?
我正在尝试配置我的API路由,我似乎无法绕过Swagger的这个错误:
500:{"消息":"发生错误.","ExceptionMessage":"Swagger 2.0不支持:路径'api/Doors/{OrganizationSys}'和方法'GET'的多个操作.
我明白为什么我得到错误,但我不知道如何解决它.以下是API端点:
public IHttpActionResult Get(int organizationSys)
{
....
}
public IHttpActionResult Get(int organizationSys, int id)
{
....
}
public IHttpActionResult Post([FromBody]Doors door)
{
....
}
public IHttpActionResult Put([FromBody]Doors door)
{
....
}
public IHttpActionResult Delete(int organizationSys, int id)
{
....
}
Run Code Online (Sandbox Code Playgroud)
这是我的路线,显然不正确:
config.Routes.MapHttpRoute(
name: "route1",
routeTemplate: "api/{controller}/{organizationSys}"
);
config.Routes.MapHttpRoute(
name: "route2",
routeTemplate: "api/{controller}/{organizationSys}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}"
);
Run Code Online (Sandbox Code Playgroud)
更新:
我现在有这个,但得到同样的错误:
config.Routes.MapHttpRoute(
name: "route1",
routeTemplate: "api/{controller}/{organizationSys}/{id}"
);
config.Routes.MapHttpRoute(
name: "route2", …
Run Code Online (Sandbox Code Playgroud) 好。我制作了一个简单的控制台应用程序,以弄清楚如何完成所有这些工作。一旦基本轮廓开始工作,然后将其应用于实际应用程序。
这个想法是,我们要执行很多数据库调用,这将花费很长时间。我们不想(或不必)等待一个数据库调用完成之后再进行下一个。它们可以同时运行。
但是,在进行所有调用之前,我们需要执行“启动”任务。当所有调用完成后,我们需要执行“完成”任务。
这是我现在的位置:
static void Main(string[] args)
{
Console.WriteLine("starting");
PrintAsync().Wait();
Console.WriteLine("ending"); // Must not fire until all tasks are finished
Console.Read();
}
// Missing an "await", I know. But what do I await for?
static async Task PrintAsync()
{
Task.Run(() => PrintOne());
Task.Run(() => PrintTwo());
}
static void PrintOne()
{
Console.WriteLine("one - start");
Thread.Sleep(3000);
Console.WriteLine("one - finish");
}
static void PrintTwo()
{
Console.WriteLine("two - start");
Thread.Sleep(3000);
Console.WriteLine("two - finish");
}
Run Code Online (Sandbox Code Playgroud)
但是,无论我尝试什么,Ending
总是打印得太早:
starting
ending
one - start
two …
Run Code Online (Sandbox Code Playgroud) 有没有办法从得到$product
的$subscription
?
感谢这篇文章,我知道$subscription
我可以得到$order
:
$order = $subscription->order;
Run Code Online (Sandbox Code Playgroud)
这有可能吗?
$product = $subscription->product;
Run Code Online (Sandbox Code Playgroud)
要么:
$product = $order->product;
Run Code Online (Sandbox Code Playgroud) 使用Dapper或Dapper.SimpleCRUD,如何从表中删除列表。就像是:
public static void DeleteList<T>(List<T> listToDelete)
{
using (var connection = OpenConnection())
{
connection.Delete<T>(listToDelete);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试时,我得到...
类型DataModel.MyTable的成员不能用作参数值
是传递WHERE子句的唯一选择吗?
I need to filter a List<object>
so that I remove any items where a string
property does not exist inside another List<string>
.
I created this console app just to make sure I had the LINQ syntax correct:
class FooBar
{
public int Id { get; set; }
public string ValueName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
and then...
List<FooBar> foobars = new List<FooBar>
{
new FooBar { Id = 1, ValueName = "Val1" },
new FooBar { Id = 2, …
Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×4
asp.net ×2
asp.net-mvc ×2
async-await ×1
asynchronous ×1
dapper ×1
encryption ×1
icons ×1
javascript ×1
jquery ×1
json ×1
linq ×1
model ×1
null ×1
performance ×1
php ×1
product ×1
swagger ×1
url-encoding ×1
windows ×1
woocommerce ×1
wordpress ×1