我正在尝试从网站下载图像并根据该图像创建位图.它看起来像这样:
public void test()
{
PostWebClient client = new PostWebClient(callback);
cookieContainer = new CookieContainer();
client.cookies = cookieContainer;
client.download(new Uri("SITE"));
}
public void callback(bool error, string res)
{
byte[] byteArray = UnicodeEncoding.UTF8.GetBytes(res);
MemoryStream stream = new MemoryStream( byteArray );
var tmp = new BitmapImage();
tmp.SetSource(stream);
}
Run Code Online (Sandbox Code Playgroud)
我在回调方法的最后一行收到"未指定的错误".有趣的事实是,如果我使用BitmapImage(新的Uri("SITE"))它运作良好...(我不能这样做因为我想从该URL抓取cookie.图像是jpg.PostWebClient类- > http://paste.org/53413
我有一个使用SQL Server CE 4.0和Entity Framework 4.0的ASP.NET项目.它在我的本地计算机上工作正常.
但是,当我将它移动到远程服务器,并尝试登录到程序的管理部分时,我收到以下错误:
The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
Run Code Online (Sandbox Code Playgroud)
它引用了远程服务器上machine.config中的以下行:
Line 237: <membership>
Line 238: <providers>
Line 239: <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
Line 240: </providers>
Line 241: </membership>
Run Code Online (Sandbox Code Playgroud)
现在,我的web.config中没有"AspNetSqlMembershipProvider"语句,它引用了一个名为"LocalSqlServer"的连接字符串.相反,我有以下内容:
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" connectionStringName="PUGConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
Run Code Online (Sandbox Code Playgroud)
这实际上在本地工作.连接字符串的名称是PUGConnection,而不是LocalSqlServer. …
asp.net asp.net-membership membership-provider sql-server-ce entity-framework-4
这是我的DefaultApi配置:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}/{action}",
defaults: new { action = "DefaultAction", id = RouteParameter.Optional }
);
[ActionName("DefaultAction")]
public HttpResponseMessage Get(string id)
[ActionName("DefaultAction")]
public HttpResponseMessage Post(MyClass obj)
Run Code Online (Sandbox Code Playgroud)
怎么GET
工作,但使用POST
我得到一个404 Not Found
错误?
任何想法或建议?
编辑:
客户端JavaScript:
$.ajax({
type: "POST",
url: "@Url.Content("~/api/controllername")",
data: args,
200: function (data) {
......
}
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Insomnia 与客户端证书一起使用。我从 Insomnia 文档中遵循了此文档。我添加了我的证书 pem 文件和密码。
问题是我仍然收到此错误:
错误:无法连接到服务器。
你知道为什么吗?谢谢。
我有一个控制器被调用HotelsController
来插入和编辑酒店。
它具有以下设置(为简单起见删除了方法实现):
[RoutePrefix("{member_id:int}/hotels")]
public class HotelsController : ApplicationController
{
[Route("delete/{id:int}", Name = NamedRoutes.HotelDelete)]
public ActionResult Delete(int id)
{
}
[Route("new", Name = NamedRoutes.HotelNew)]
public ActionResult New()
{
}
[HttpPost]
[ValidateInput(false)]
public ActionResult New(HotelDataEntry hotel)
{
}
[Route("edit/{id:int}", Name = NamedRoutes.HotelEdit)]
public ActionResult Edit(int id)
{
}
[HttpPost]
[ValidateInput(false)]
public ActionResult Edit(HotelDataEntry hotel)
{
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,以下路由使用了属性路由:
以下路由不使用属性路由:
路由在 Global.asax.cs 中设置如下:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
Routen.Standard.ToString(), …
Run Code Online (Sandbox Code Playgroud) c# asp.net asp.net-mvc-routing attributerouting asp.net-mvc-5
如何将一个SQL select
语句的结果用作另一个SQL select
语句的列?
例如:
select a, b,
(select t from other_table where other_table.id = my_table.a) as c
from my_table
Run Code Online (Sandbox Code Playgroud)
如果结果other_table
为一个记录,则没有问题。但是,如果它有多个记录,它将失败。
我有两个对象数组:
var a = [
{id: 4, name: 'Greg'},
{id: 1, name: 'David'},
{id: 2, name: 'John'},
{id: 3, name: 'Matt'},
]
var b = [
{id: 5, name: 'Mathew', position: '1'},
{id: 6, name: 'Gracia', position: '2'},
{id: 2, name: 'John', position: '2'},
{id: 3, name: 'Matt', position: '2'},
]
Run Code Online (Sandbox Code Playgroud)
我想要做的内连接这两个阵列a
和b
,并创建一个第三阵列像这样(如果位置属性不存在,则它变为零):
var result = [{
{id: 4, name: 'Greg', position: null},
{id: 1, name: 'David', position: null},
{id: 5, name: 'Mathew', position: '1'},
{id: 6, …
Run Code Online (Sandbox Code Playgroud) 据我了解getComputedStyles()方法,它应该返回一个对象,该对象允许访问 HTML 元素节点的实际 CSS 属性值。
我用一个包含跨度的段落创建了这个简单的例子:
let span = document.getElementsByTagName("span")[0];
let style = window.getComputedStyle(span);
span.innerText = "span background-color is " + style.getPropertyValue("background-color");
Run Code Online (Sandbox Code Playgroud)
<p style="background-color: orange">
<span style="color: green">Empty</span>
</p>
Run Code Online (Sandbox Code Playgroud)
段落的背景颜色是orange
,所以跨度也应该有那个属性值,还是我弄错了?是否会忽略继承的值getComputedStyles
?如果是这样,我怎样才能获得跨度的实际可见背景颜色?谢谢你。
我查阅了 JavaScript 的历史,发现 ECMAScript 规范是基于它的。所以 JavaScript 比 ECMAScript 更旧,但似乎后来成为该规范的实现。
所以到目前为止我发现的是:
在 JavaScript 1.8.5 版本之后,我找不到它的任何更高版本号。哪些版本的 JavaScript 实现了 ECMAScript 6 或 7?
我有一个名为的 TypeScript 文件listeners.ts
,它定义了如下事件侦听器:
export function TimeField_OnChange () {
// ...
}
Run Code Online (Sandbox Code Playgroud)
我想在其中index.html
使用这个函数(这不起作用):
document.getElementById("timeFieldCheckBox").addEventListener("change", TimeField_OnChange);
Run Code Online (Sandbox Code Playgroud)
浏览器 JavaScript 引擎无法找到该函数。我该如何正确引用它?
javascript ×4
asp.net ×3
c# ×3
html ×2
api ×1
arrays ×1
css ×1
inner-join ×1
rest ×1
rest-client ×1
select ×1
sql ×1
sql-server ×1
t-sql ×1
typescript ×1