在我的mvc项目中,我有一个简单的项目列表,其中包含如下所示的crud操作:
<tbody>
@{
foreach (var item in Model)
{
<tr>
<td>@item.Title</td>
<td>@item.Body</td>
<td>@item.Price</td>
<td><span class="EditLink ButtonLink" noteid="@item.Id">Edit</span> | <span>@Html.ActionLink("Delete", "Delete", new { id = @item.Id})</span>
| @Html.ActionLink("Detalji", "Details", new { id = @item.Id})
</td>
</tr>
}
}
</tbody>
Run Code Online (Sandbox Code Playgroud)
我想知道当我点击详细信息时,可以将详细信息视图呈现为表格下的部分视图.我的意思是当我clik细节向我展示细节视图时,我希望它在我的桌子下面的某个div或段落中.
请帮忙.
我正在尝试将两个文本文件压缩为zip文件.这是我的公共方法的样子:
public ActionResult Index()
{
byte[] file1 = System.IO.File.ReadAllBytes(@"C:\file1.txt");
byte[] file2 = System.IO.File.ReadAllBytes(@"C:\file2.txt");
Dictionary<string, byte[]> fileList = new Dictionary<string, byte[]>();
fileList.Add("file1.txt", file1);
fileList.Add("file2.txt", file2);
CompressToZip("zip.zip", fileList);
return View();
}
Run Code Online (Sandbox Code Playgroud)
这就是我的压缩方法的样子:
private void CompressToZip(string fileName, Dictionary<string, byte[]> fileList)
{
using (var memoryStream = new MemoryStream())
{
foreach (var file in fileList)
{
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
var demoFile = archive.CreateEntry(file.Key);
using (var entryStream = demoFile.Open())
using (var b = new BinaryWriter(entryStream))
{
b.Write(file.Value);
}
}
} …Run Code Online (Sandbox Code Playgroud) 我的identityserver4客户端如下所示:
new Client {
ClientId = "openIdConnectClient",
ClientName = "Example Implicit Client Application",
//AllowedGrantTypes = GrantTypes.Implicit,
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true,
AccessTokenLifetime = 30,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"role",
"customAPI.write"
},
RedirectUris = new List<string> {"http://localhost:8080/callback"},
PostLogoutRedirectUris = new List<string> {"https://localhost:44330"},
AllowedCorsOrigins = new List<string>
{
"http://127.0.0.1:8080",
"http://localhost:8080",
"*"
},
}
Run Code Online (Sandbox Code Playgroud)
在react应用程序中,我的userManager类如下所示:
import { createUserManager } from 'redux-oidc';
const userManagerConfig = {
client_id: 'openIdConnectClient',
redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码对我的MVC模型进行编码,但警报消息为我提供了一个空值.我不确定它为什么给我一个空值,因为这是一个创建表单.我正在尝试从这个创建一个模型,我的HTML代码具有以下外观:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Customer</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" id="submit" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index") …Run Code Online (Sandbox Code Playgroud) 我的反应组件如下所示:
class App extends React.Component {
render() {
debugger;
if(!this.props.isUserExist) {
return (
<div>
<Route exact path="/" component={DashboardPage} />
</div>
);
}
return (
<div>
<Switch>
<Route exact path="/" component={HomePage} />
<Route exact path="/list" component={ListPage} />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:有没有更好的方法来使用 react router v4 检查这些条件?这是检查这些条件的最佳方法吗?这是最佳做法吗?请有人帮我解决这个问题!
asp.net ×2
jquery ×2
react-redux ×2
redux ×2
.net ×1
ajax ×1
asp.net-ajax ×1
asp.net-mvc ×1
c# ×1
compression ×1
file ×1
javascript ×1
json ×1
razor ×1
react-router ×1
reactjs ×1
redux-saga ×1
redux-thunk ×1