0
많은 텍스트 상자가있는 사이트에서 작업하고 있습니다. 그러나 요청을 다시 사이트에 올리면 내 URL이 오랫동안 길어진다는 오류가 발생합니다. 요청이 양식 정보를 URL로 보내거나 잘못 되었기 때문입니다.요청이 길어질 URL을 반환합니다.
어쨌든 내가 찾고있는 것은이 문제를 해결하는 방법입니다.
start.cshtml
@using Handbook.App_Code
@using System.Text
@{
ViewBag.Title = "Start";
Layout = "~/Views/Shared/_Layout.cshtml";
StringBuilder wordText = new StringBuilder();
if (QuestionArray.Instance.Questions.Count == 0)
{
tempClass.setQuestions();
}
List<Question> temp = QuestionArray.Instance.Questions;
List<string> categories = new List<string>();
foreach(var z in QuestionArray.Instance.Questions)
{
bool newCat = true;
foreach (var e in categories)
{
if (z.Categori == e)
{
newCat = false;
}
}
if(newCat)
{
categories.Add(z.Categori);
}
}
if (Request["btn"] == "save")
{
QuestionArray.Instance.Questions = null;
QuestionArray.Instance.Questions = new List<Question>();
foreach (var q in temp)
{
var qTemp = new Question();
qTemp = q;
qTemp.Answer = Request.Unvalidated("question" + q.Id);
QuestionArray.Instance.Questions.Add(qTemp);
}
wordText.Append("<h1 style='text-align:center;'>Varmemester Håndbogen</h1>");
foreach (var x in categories)
{
wordText.Append("<h3 style='text-align:center;'>" + x + "</h3>");
foreach (var x2 in QuestionArray.Instance.Questions)
{
if (x2.Categori == x)
{
wordText.Append("<p>" + x2.Answer + "</p>");
}
}
}
DocumentHandler.GenerateDocument(wordText.ToString());
}
}
<div style="margin:auto; width:600px;" class="hidden-print">
<form role="form">
@{
foreach (var x in categories)
{
<h2>@x</h2>
foreach (var x2 in QuestionArray.Instance.Questions)
{
if (x2.Categori == x)
{
string tempId = "question" + x2.Id;
<div class="form-group">
<label>@x2.MyQuestion</label>
<textarea class="form-control" style="height:200px;" name="@tempId"></textarea>
</div>
}
}
<hr style="height:3px; background-color:#333;" />
}
}
<button type="submit" class="btn btn-success">Afslut</button>
<button type="submit" name="btn" value="save" class="btn btn-success">Gem</button>
</form>
</div>
DocumentHandler.cs 그런데
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Filters;
using System.Web.Mvc;
using System.Text;
namespace Handbook.App_Code
{
public class DocumentHandler
{
public static void GenerateDocument(string code)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/msword";
string strFileName = "GenerateDocument" + ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
StringBuilder strHTMLContent = new StringBuilder();
strHTMLContent.Append("<html " +
"lang='da' xml:lang='da'" +
"xmlns:o='urn:schemas-microsoft-com:office:office' " +
"xmlns:w='urn:schemas-microsoft-com:office:word'" +
"xmlns='http://www.w3.org/TR/REC-html40'>" +
"<head><META charset='utf-8' /><title>Time</title>");
//The setting specifies document's view after it is downloaded as Print
//instead of the default Web Layout
strHTMLContent.Append("<!--[if gte mso 9]>" +
"<xml>" +
"<w:WordDocument>" +
"<w:View>Print</w:View>" +
"<w:Zoom>90</w:Zoom>" +
"<w:DoNotOptimizeForBrowser/>" +
"</w:WordDocument>" +
"</xml>" +
"<![endif]-->");
strHTMLContent.Append("<style>" +
"</style></head>");
strHTMLContent.Append("<body style='tab-interval:.5in'>" +
code + "</body></html>");
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}
}
}
는, 메신저 MVC4에서 작업
편집 내가, 내 코드에서 찾아 봤는데와 좀 더 그물에. 그리고 내가 볼 수있는 것은 허용 된 URL 범위 내에서 내 사이트에서 트래픽을 늘려야한다는 것입니다. 그건 내가 원하는 것이 아니야. 그래서 누군가가이 요청을 해결할 생각이 있다면. 그러나 나는 기뻐할 것 같은 결과를 얻는다.