我需要用一个请求发送到带有JSON(最好)的Api控制器.
问题是传递数据和文件(图像上传).我的财产空了(null).
我看了很多博客,但似乎无法通过图像传递数据.
public class SomeModel
{
public string Name { get; set; }
public string Email { get; set; }
public string City { get; set; }
public HttpPostedFileBase Image { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string CountryCode { get; set; }
}
[HttpPost]
public void CreateContestEntry(SomeModel model)
{
// model.Image is always null
// .. get image here - the other properties no issues
} …
Run Code Online (Sandbox Code Playgroud) 这个问题从IE9开始,对于POST
请求,contentType
必须是text/plain
,并且application/json
将不起作用.
我添加了moonscript并继续使用contentType: text/plain
.我还将自定义媒体类型添加到api中,如下面的多种表单所示:
并添加了text/plain
媒体类型的插入WebApiConfig
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
// allows 'text/plain' as a supported media type
config.Formatters.Add(new TextMediaTypeFormatter());
Run Code Online (Sandbox Code Playgroud)
但是,当在IE9中发布(使用仿真)时,我仍然收到了 415 Unsupported Media Type
Key Value
Response HTTP/1.1 415 Unsupported Media Type
$.ajax({
type: "POST",
url: hope_forms.viivApiUrl + 'newsletter',
contentType: 'text/plain',
data: JSON.stringify(model),
success: function (data) {
.....
},
error: function (responseText) {
console.log(responseText)
modal.showModal('Something went wrong, please …
Run Code Online (Sandbox Code Playgroud) c# jquery internet-explorer-9 asp.net-web-api mediatypeformatter
问题是关于使用Route
属性定义自定义路由.
我知道在WebApiConfig
课堂上你总是定义默认路线,
configuration.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
Run Code Online (Sandbox Code Playgroud)
当我想要传递另一个参数时,我无法工作的是什么.我知道我可以这样做(下面的代码定义在上面列出的默认路由下面):
//configuration.Routes.MapHttpRoute(
// name: "GetBrandImagePaths",
// routeTemplate: "api/{controller}/{id}/{type}");
Run Code Online (Sandbox Code Playgroud)
但我宁愿WebApiConfig
使用自定义路由,而不是在文件中定义所有这些路由.但是,如果我在文件中没有上面注释掉的代码,我会得到一个404.导致我相信自定义Route
甚至没有被查看.
public class HelperApiController : ApiController
{
[HttpGet]
[Route("api/helperapi/{id}/{type}")]
public string GetBrandImages(int id, string type)
{
.....
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么能拥有它所以我可以使用WebApiConfig
文件中定义的路由,并在各个API控制器中定义自定义路由.
请注意,该项目也是一个MVC项目(不仅仅是WebApi).有什么我错过了,做错了等吗?我知道那里有很多帖子定义了如何传递多个参数,但我认为我的问题更具体地说明为什么一个有效而另一个无效.
我正在创建电子邮件模板,我发现了这个CSS支持指南,但box-sizing
不在那里.我想知道是否支持CSS属性,如果是,哪个电子邮件客户端支持它.
我已经这样做了100万次了......
我已经进入 IIS 检查“Windows 功能”中是否选中了“静态内容”复选框,确实如此。
我没看到什么?
另外,例如,当我浏览到“ http://local.xxx-xxx.com/source/sass/main.min.css ”时,我得到:
HTTP 错误 404.0 - 未找到 您正在查找的资源已被删除、名称已更改或暂时不可用。
我需要同时拥有https
和non-www
重写,同时也不对域进行硬编码,因为我们有许多服务器。这需要在 中web.config
,而不是在IIS
.
我读过很多文章:
该https
重写作品中,non-www
没有。
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<!--<add input="{CACHE_URL}" pattern="*://www.*" />-->
<!--<add input="{HTTP_HOST}" pattern="*://www.*" />-->
<add input="{HTTP_HOST}" pattern="^.*www.*" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
// i've also tried
// url="{C:2}/{R:1}"
// url="{C:1}/{C:2}" …
Run Code Online (Sandbox Code Playgroud) 我知道zip中的缩小文件只是基本代码,不包含库.因此,我运行该build.sh
文件,它生成了我已包含在我的脚本中的另一个缩小文件.
期望:
点击时我试图放大标记.我有一个在事件上运行的函数onMarkerClick
.
问题:
我看过(2)不同的帖子:
这两个帖子都会产生同样的错误.
错误:
Error: <g> attribute transform: Expected number, "scale(NaN) translate(N…". jquery.jvectormap.min.js:733
733行 - this.rootElement.node.setAttribute('transform', 'scale('+scale+') translate('+transX+', '+transY+')');
显然+scale+
不是数字(NaN)
我想将日志写入Json文件
newEntry = "User: " + lastUsername + " Time: "+now+ " Door: "+IOSDoor;
lastUserOpenClose += newEntry;
jsonString = JSON.stringify(lastUserOpenClose);
fs.writeFile("lastUserOpenClose.json", lastUserOpenClose, function(err) {
if(err) {
console.log(err);
} else {
console.log("Server-Log: The file was saved!");
}
});
Run Code Online (Sandbox Code Playgroud)
但我正在覆盖日志.如何将somthing写入json文件并且不覆盖旧日志?
可能是愚蠢的问题,但我以前没有和Culture一起工作过.该日期的资产需要是:
MMMM dd"de"yyyy(没有引用"de").
junio 1 de 2015
我现在拥有的:
CultureInfo ci = new CultureInfo("es-ES", false);
string date = DateTime.Now.ToString("MMMM dd REPLACE yyyy", ci).Replace("REPLACE", "de");
Run Code Online (Sandbox Code Playgroud)
我想知道是否有一种"编程更正确"的做法,我不知道这样做而不是做 string.Replace
我看过两个:
问题:
每次unicode字符都出现在.breadcrumbs
和.hero
div 之间的完全相同的位置(某些页面没有.actions
容器,以防万一您想知道)。
使用Sitecore 8(CMS)。我不知道这是从哪里来的。它仅在几页上发生,我想我已将其范围缩小到(2)个渲染图。我按照上面(2)个博客文章之一的建议,将HTML从VS中复制到了Notepad ++中,然后将其从Notepad中重新复制回了VS中。但是,这不起作用,因此使我相信该Unicode某种程度上来自CMS。
我的问题:
该站点即将(几天之内)即将投入生产,我需要快速修复(或者这可能是唯一的修复)。
.hero
和.breadcrumbs
,然后去除unicode字符,这是否是最佳选择(按时间排序)?
还是其他?(即-
U+FEFF
等)我在许多项目中使用过Umbraco 7,但从未使用过Umbraco 6.该项目确实是一个MVC项目.
我之前在这个关于模板的项目中遇到了类似的问题.创建模板时,它会创建一个.aspx页面,而不是视图.我换了一个配置设置在/Config/umbracoSettings.config从Web表单到的mvc
<templates>
<!-- If you want to switch to Mvc then do NOT change useAspNetMasterPages to false -->
<!-- This (old!) setting is still used to control how macros are inserted into your pages -->
<useAspNetMasterPages>true</useAspNetMasterPages>
<!-- To switch the default rendering engine to MVC, change this value from WebForms to Mvc -->
<!-- Do not set useAspNetMasterPages to false, it is not relevant to MVC usage -->
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
Run Code Online (Sandbox Code Playgroud)
但是,在创建内容节点时,属性页面上的默认"链接到文档"确实是一个.aspx
扩展名.如何删除它,只有默认视图名称,而不是扩展名?
我知道有重写,但如果它是一个MVC项目那么为什么甚至首先在那里扩展呢?我没有必要在Umbraco 7中这样做.
使用Bootstrap v3 - 我有(2)个选项卡,每个选项卡都有一个表单.第一个标签的形式比第二个标签的形状小得多(高度).我尝试了几种不同的方法.
两种方法都使用以下标记:
<div id="container" class="account">
<header class="clearfix">
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active">
<a href="#ingresar" data-toggle="tab">Ingresar</a>
</li>
<li>
<a href="#crear-una-cuenta" data-toggle="tab">Crear una cuenta</a>
</li>
</ul>
</header>
</div>
<div class="account-container">
<div class="tab-content row">
<div class="col-md-8">
<div id="ingresar" class="tab-pane fade in active">
// form here ***********
</div>
<div id="crear-una-cuenta" class="tab-pane fade">
// loooooong form here ************
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
您可以在下面的小提琴中看到没有CSS应用,当第二个表单的选项卡处于活动状态时,第二个表单上方的第一个表单中有空格
因此,我添加了下面的CSS,当第二个选项卡处于活动状态时,"空白空间"不再存在.
.account-container .fade {
height: 0;
}
.account-container .fade.in {
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
现在第二个标签上的空格消失了.但是,第一个选项卡在表单下方有大量空间(从隐藏的第二个表单).
我试图从我的localhost复制我的问题,但是当第一个选项卡处于活动状态时,您仍然可以突出显示隐藏的第二个选项卡中的输入,并输入文本.(见图)
所以当我通过添加一些额外的CSS来激活选项卡时,我试图隐藏表单 …