我正忙着创建Web API(在asp mvc4应用程序中).我正在使用asp.net网站上建议的库来生成文档(http://www.asp.net/web-api/overview/creating-web-apis/creating-api-help-pages).
我的问题是,如果我的参数是模型,那么我无法在生成的帮助页面中指定模型包含的属性.
这是一个例子:
模型:
public class TestModel
{
property String FirstName {get;set;}
property String Surname {get; set;}
property Boolean Active {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
行动:
/// <summary>
/// This is a test action
/// </summary>
/// <param name="model">this is the model</param> <-- this works
/// <param name="FirstName">This is the first name </param> <-- doesn't work
/// <param name ="model.Surname">This is the surname</param> <-- doesn't work
public HttpResponseMessage Post(my.namespace.models.TestModel model)
{
...
}
Run Code Online (Sandbox Code Playgroud)
仅生成模型的参数.
我看了一下为文档生成的xml文档,它确实添加了其他参数.
<member name="my.namespace.api.Post(my.namespace.models.TestModel)">
<summary>
this …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-apiexplorer
正如标题所述,我想在局部视图中定义一个部分.
我测试过的代码如下:
控制器:
public ActionResult Test()
{
return View();
}
public ActionResult PartialTest()
{
return PartialView("_PartialTest");
}
Run Code Online (Sandbox Code Playgroud)
Test.cshtml:
@{
ViewBag.Title = "Test";
}
<h2>Test</h2>
@Html.Action("PartialTest")
Run Code Online (Sandbox Code Playgroud)
_PartialTest.cshtml:
<p>partial Test</p>
@section scripts {
<script type="text/javascript">
$(document).ready(function() {
alert("Test");
});
</script>
}
Run Code Online (Sandbox Code Playgroud)
将该部分scripts放在Test.cshtml中可以正常工作,因此问题不在布局中.
有人知道怎么做吗?
我正在使用itext sharp在我的模板上用值填充我的表单字段.
我使用pdfescape.com创建了模板
这是我用来将值放在pdf模板中的代码.
private static byte[] GeneratePdf(Dictionary<String, String> formKeys, String pdfPath)
{
var templatePath = System.Web.HttpContext.Current.Server.MapPath(pdfPath);
var reader = new PdfReader(templatePath);
var outStream = new MemoryStream();
var stamper = new PdfStamper(reader, outStream);
var form = stamper.AcroFields;
var fieldKeys = form.Fields.Keys;
// "Flatten" the form so it wont be editable/usable anymore
// stamper.FormFlattening = true;
foreach (KeyValuePair<String, String> pair in formKeys)
{
if (fieldKeys.Any(f => f == pair.Key))
{
form.SetField(pair.Key, pair.Value);
form.SetFieldProperty(pair.Key, "setfflags", PdfFormField.FF_READ_ONLY, null);
}
}
stamper.Close(); …Run Code Online (Sandbox Code Playgroud)