当使用Url.Action帮助程序自动生成Urls时,如果页面包含类似于的行
@ Url.Action( "编辑", "学生")
预计将产生一个像domain/student/edit它一样的URL 并且它按预期工作.但是,如果请求的URL包含一些参数,例如domain/student/edit/210,上面的代码使用前一个请求中的这些参数并生成类似的东西,即使我没有为该Action方法提供任何此类参数.
简而言之,如果请求的网址包含任何参数,则无论我是否在Url.Action方法中指定,任何自动生成的网页链接(为该请求提供服务)都将包含这些参数.
出了什么问题?
我正在尝试像Windows 8瓷砖一样的东西,并希望显示不同宽度和/或高度的瓷砖.WrapPanel使每列的宽度和高度相等,在较小的项目周围留下空白.是否有一种方式或面板来显示项目,就像StackPanel每个项目可以有各自的尺寸和包裹像WrapPanel?
编辑:这是我的ItemsControl.我取代了瓷砖的DataTemplate用一个简单的Border和TextBlock.宽度为auto和Tiles看起来很好,除了WrapPanel创建相同大小的单元格.
<ItemsControl ItemsSource="{Binding Path=Contents}" HorizontalContentAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="#B1DBFC" Height="200px" BorderBrush="#404648" Margin="5">
<TextBlock VerticalAlignment="Center" Text="{Binding Path=Name}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)

您可以从图像中看到width每列的宽度是最宽的项目的宽度.
如果我在边框上明确设置宽度,事情会变得更加难看.

有没有办法在c#或vb.net中执行此操作?我必须使系统退出待机状态,并在特定时间间隔处于待机模式时播放通知声音.这可能吗?
我正在使用带有 axios 的 next.js API 路由,我的 api 在下面给了我警告
API 已解析,但未发送 /api/authentication/login 的响应,这可能会导致请求停滞。
我找不到我做错了什么
import axios from 'axios'
import type { NextApiRequest, NextApiResponse } from 'next'
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
axios({
method: 'post',
headers : { 'Content-type': 'application/json' },
url: `${process.env.WEB_API_URL}/authentication/login`,
data: req.body,
})
.then((results) => {
res.status(results.status).json(results.data)
})
.catch((error) => {
res.status(error.status).json(error.response.data)
})
}
export default handler
Run Code Online (Sandbox Code Playgroud) 我想一定路线地图,以便自动生成的URL看起来
Admin/controller/action/param对于这两个代码块,
@Url.Action("action","controller",new{id="param"})并
@Url.Action("action","controller",new{type="param"})
我所做的是在区域注册中的以下内容,
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index",
id = UrlParameter.Optional },
new string[] { "namespaces" });
context.MapRoute(
"Admin_type",
"Admin/{controller}/{action}/{type}",
new { action = "Index",
type = UrlParameter.Optional },
new string[] { "namespaces" });
Run Code Online (Sandbox Code Playgroud)
当参数名称是id,生成的url是预期的,但是当参数名称是type,而不是controller/action/typevalue,它生成类似的东西controller/action/?type=typevalue
有没有办法生成url类似于controller/action/typevalue保持Admin_default路由器的生成器行为完好无损?
asp.net-mvc asp.net-mvc-routing asp.net-mvc-areas asp.net-mvc-3
我正在使用asp.net项目,用户可以将文件上传到服务器.我想用原始名称保存文件,但是如果已经存在同名文件我怎样才能在括号中生成带有数字的文件名,就像windows一样?
文件将上载到特定文件夹,并使用其客户端名称本身进行保存.因此,如果上传了名为myimage.jpg的文件并且服务器中已存在同名文件,我需要将其重命名为myimage(1).jpg或者如果'myimage.jpg'重命名为'myimage(n).jpg '存在,我需要将其重命名为myimage(n + 1).jpg.
搜索和生成此类文件名的最佳方法是什么?我的第一个猜测是使用带有正则表达式的linq DirectoryInfo.EnumerateFiles(),但这是一个好方法吗?