网站加端口号,就显示查找不到资源

jackiecheng001 2006-08-15 09:34:38
private static string UrlSuffix
{
get
{
return HttpContext.Current.Request.Url.Host +HttpContext.Current.Request.Url.Port
+ HttpContext.Current.Request.ApplicationPath;

}
}
public static String UrlBase
{
get
{
return @"http://" + UrlSuffix;

}
}

我是用上面的UrlBase做当前目录,然后RecordsManLink =PathPrefix + "/RecordsMan.aspx";
这样建立连接
问题: 同样的配置,设置为默认网站就一切ok,可一旦设置了端口,就会出现问题!
...全文
300 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackiecheng001 2006-09-19
  • 打赏
  • 举报
回复
痛苦啊 一直没有人来 自己顶下 来过留言啊 兄弟门
AFatPig 2006-09-19
  • 打赏
  • 举报
回复
学习
jackiecheng001 2006-09-08
  • 打赏
  • 举报
回复
static private string UrlSuffix
{
get
{
if(HttpContext.Current.Request.Url.IsDefaultPort)
{
return HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
}
else
{
return HttpContext.Current.Request.Url.Host +
@":" + HttpContext.Current.Request.Url.Port + HttpContext.Current.Request.ApplicationPath;
}

}
}
这样也不行
public static String UrlBase
{
get
{
return @"http://" + UrlSuffix;
// return HttpContext.Current.Request.ApplicationPath ;

}
}
jackiecheng001 2006-08-31
  • 打赏
  • 举报
回复
yinlei109(鲤鱼
也不可以的
yinlei109 2006-08-28
  • 打赏
  • 举报
回复
private static string UrlSuffix
{
get
{
return HttpContext.Current.Request.Url.Host +HttpContext.Current.Request.Url.Port
+ HttpContext.Current.Request.ApplicationPath+":9000";

}
9000是你项目在ISS里的端口号 你试一下
jackiecheng001 2006-08-15
  • 打赏
  • 举报
回复
js
jackiecheng001 2006-08-15
  • 打赏
  • 举报
回复
js
jackiecheng001 2006-08-15
  • 打赏
  • 举报
回复
那到底加上端口号的写法是怎样的啊
qwerttyy 2006-08-15
  • 打赏
  • 举报
回复
直接用HttpContext.Current.Request.ApplicationPath就好了。
chrislv 2006-08-15
  • 打赏
  • 举报
回复
用相对路径就好了,不要用绝对
jackiecheng001 2006-08-15
  • 打赏
  • 举报
回复
顶下了
jackiecheng001 2006-08-15
  • 打赏
  • 举报
回复
你的链接也要加上端口,不然会用默认的80端口
能不能说明白点,给点代码好不?
谢谢?

我前面的目录已经加上端口号了啊
  • 打赏
  • 举报
回复
学习 帮顶
lxhvc 2006-08-15
  • 打赏
  • 举报
回复
你的链接也要加上端口,不然会用默认的80端口

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧