Click here to Skip to main content
15,903,385 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: avoid postback Pin
Nouman Bhatti23-May-07 1:16
Nouman Bhatti23-May-07 1:16 
GeneralRe: avoid postback Pin
iamdking23-May-07 1:27
iamdking23-May-07 1:27 
GeneralRe: avoid postback Pin
Sherin Iranimose23-May-07 1:36
Sherin Iranimose23-May-07 1:36 
GeneralRe: avoid postback [modified] Pin
Nouman Bhatti23-May-07 2:17
Nouman Bhatti23-May-07 2:17 
AnswerRe: avoid postback Pin
Amit Kumar G23-May-07 1:34
Amit Kumar G23-May-07 1:34 
QuestionAsphostingpermission in asp.net using c# Pin
attalurisubbu23-May-07 0:29
attalurisubbu23-May-07 0:29 
AnswerRe: Asphostingpermission in asp.net using c# Pin
N a v a n e e t h23-May-07 0:49
N a v a n e e t h23-May-07 0:49 
GeneralRe: Asphostingpermission in asp.net using c# [modified] Pin
attalurisubbu23-May-07 2:55
attalurisubbu23-May-07 2:55 
Hi,
I created one user with name "srinivasanb" and pwd "Mpls7880" in my system giving full rights for that user( In my system only i have docs folder for file server) and same username & pwd was created on host system there also giving full rights for that user.

In put web.config and data.config and bin folder,template folder,xml folder,documents folders in docs folder in my system.

In web.config file i included the following code
------------------------------------------------

httpHandlers
add verb="*" path="*.pdf" type="Coverpoint.WillisBloodstock.BusinessServices.FileHandler,BusinessServices"
add verb="*" path="*.doc" type="Coverpoint.WillisBloodstock.BusinessServices.FileHandler,BusinessServices"
add verb="*" path="*.xml" type="Coverpoint.WillisBloodstock.BusinessServices.FileHandler,BusinessServices"
add verb="*" path="*.xls" type="Coverpoint.WillisBloodstock.BusinessServices.FileHandler,BusinessServices"
/httpHandlers

add key="WebSiteURL" value="http://localhost/Bloodstock2.2/"/

authentication mode="None"/

authorization
allow users="*"/
/authorization

In globalization tag i am giving the username and password which were created in my system and hosted machince (on both machines users should have same name and pwd)

identity impersonate="true" userName="zslindia\srinivasanb"
password="Mpls7880" /

Note:I removed less thn and greater than symbols ( tags )in web.config please recognise so that to print user friendly

login.aspx
----------
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(

1,

txtUserName.Text.Trim(),

DateTime.Now,

DateTime.Now.AddMinutes(180),

true,

txtPassword.Text.Trim(),

FormsAuthentication.FormsCookiePath);



// Encrypt the ticket.

string encTicket = FormsAuthentication.Encrypt(ticket);



// Create the cookie.

Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

//Response.Cookies.Add(new HttpCookie("username", euser.UserName));

Response.Cookies.Add(new HttpCookie("userid", euser.UserId.ToString()));
//Userinfo is put into session object

Session["sUserObject"] = euser;




filehandler.cs
--------------
public void ProcessRequest(System.Web.HttpContext context)
{

string FileName = context.Server.MapPath(context.Request.FilePath);
if (System.Web.HttpContext.Current.Request.Cookies["Coverpt"] == null || System.Web.HttpContext.Current.Request.Headers["Referer"] == null)
{
context.Response.Redirect(System.Configuration.ConfigurationSettings.AppSettings["WebSiteURL"] + "Common/Login.aspx?User=Anonymous&ReturnUrl=" + System.Web.HttpContext.Current.Request.RawUrl.ToString());
}
else
{
if (FileName.ToLower().EndsWith(".xls"))
{
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.WriteFile(FileName);
}
else if (FileName.ToLower().EndsWith(".doc"))
{
context.Response.ContentType = "application/vnd.ms-word";
context.Response.WriteFile(FileName);
}
else if (FileName.ToLower().EndsWith(".pdf"))
{
long appId = 0;
long originalAppId = 0;
int clauseId = 0;
FileName = FileName.ToLower();
string filename = FileName.Replace(".pdf", "");
// int lastIndex = 0;
// int stringLength = 0;
// System.IO.FileInfo a = new System.IO.FileInfo(FileName);


if (FileName.ToLower().IndexOf("endorsement") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 1)
{
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
//appId = Convert.ToInt64(filename.Substring(filename.LastIndexOf("_")+1));

}
else if (FileName.ToLower().IndexOf("wemmta") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 1)
{
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
//appId = Convert.ToInt64(filename.Substring(filename.LastIndexOf("_")+1));
}
else if (FileName.ToLower().IndexOf("certificate") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 2)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
}
else if (FileName.ToLower().IndexOf("wem") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 3)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 3]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
}
}
else if (FileName.ToLower().IndexOf("schedule") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 3)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 3]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
}
}
else if (FileName.ToLower().IndexOf("invoice") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 3)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 3]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
}
}
else if (FileName.ToLower().IndexOf("wording") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 1)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
}
else if (FileName.ToLower().IndexOf("quotation") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 1)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
}
else if (FileName.ToLower().IndexOf("clause") > 0)
{
string[] splitedString = filename.Split('_');
if (splitedString.Length > 2)
{
appId = Convert.ToInt64(splitedString[splitedString.Length - 2]);
originalAppId = Convert.ToInt64(splitedString[splitedString.Length - 1]);
}
else
{
clauseId = Convert.ToInt32(splitedString[splitedString.Length - 1]);
}
}
Int32 userId = 0;
if (System.Web.HttpContext.Current.Request.Cookies["userid"] != null)
{
userId = Convert.ToInt32(System.Web.HttpContext.Current.Request.Cookies["userid"].Value);
}
if (userId > 0)
{
DAL.CommanTask commanTaskDALObj = new CommanTask();
bool verified = commanTaskDALObj.VarifyPDFDocument(userId, appId, originalAppId, clauseId);
if (verified == true)
{
context.Response.WriteFile(FileName);
}
else
{
context.Response.Redirect(System.Configuration.ConfigurationSettings.AppSettings["WebSiteURL"] + "Common/Login.aspx?User=Anonymous&ReturnUrl=" + System.Web.HttpContext.Current.Request.RawUrl.ToString());
}
}
else
{
context.Response.Redirect(System.Configuration.ConfigurationSettings.AppSettings["WebSiteURL"] + "Common/Login.aspx?User=Anonymous&ReturnUrl=" + System.Web.HttpContext.Current.Request.RawUrl.ToString());
}

}
}


}


Now i am trying to give physical path of the pdf i am getting the following error"system.security.securityexception:request for the permission of aspnethosting permission version=1.0.5.000...culture=neutral publickeytoken=b77.." instead i need to go login.aspx page for the security purpose after login credentials were matched na i pdf will get opened that is the requirement


some time i am getting the errror please do some help regarding this task

thanks and regards,
eswar









-- modified at 9:17 Wednesday 23rd May, 2007
AnswerRe: Asphostingpermission in asp.net using c# Pin
coolestCoder23-May-07 18:33
coolestCoder23-May-07 18:33 
QuestionAdding Textboxy in JavaScript Pin
Khan.Bangash23-May-07 0:28
Khan.Bangash23-May-07 0:28 
AnswerRe: Adding Textboxy in JavaScript Pin
koolprasad200323-May-07 0:41
professionalkoolprasad200323-May-07 0:41 
GeneralRe: Adding Textboxy in JavaScript Pin
Khan.Bangash23-May-07 0:50
Khan.Bangash23-May-07 0:50 
GeneralRe: Adding Textboxy in JavaScript [modified] Pin
Sherin Iranimose23-May-07 2:07
Sherin Iranimose23-May-07 2:07 
GeneralRe: Adding Textboxy in JavaScript Pin
Khan.Bangash23-May-07 2:17
Khan.Bangash23-May-07 2:17 
GeneralRe: Adding Textboxy in JavaScript Pin
Sherin Iranimose23-May-07 2:34
Sherin Iranimose23-May-07 2:34 
AnswerRe: Adding Textboxy in JavaScript Pin
Sherin Iranimose23-May-07 0:59
Sherin Iranimose23-May-07 0:59 
GeneralRe: Adding Textboxy in JavaScript Pin
Sandeep Akhare23-May-07 1:49
Sandeep Akhare23-May-07 1:49 
GeneralRe: Adding Textboxy in JavaScript Pin
Sherin Iranimose23-May-07 2:23
Sherin Iranimose23-May-07 2:23 
GeneralRe: Adding Textboxy in JavaScript Pin
Khan.Bangash23-May-07 3:04
Khan.Bangash23-May-07 3:04 
GeneralRe: Adding Textboxy in JavaScript Pin
Sherin Iranimose23-May-07 17:42
Sherin Iranimose23-May-07 17:42 
Questionhow to delete selected item from datagrid Pin
sooreeagt23-May-07 0:02
sooreeagt23-May-07 0:02 
AnswerRe: how to delete selected item from datagrid Pin
N a v a n e e t h23-May-07 0:17
N a v a n e e t h23-May-07 0:17 
GeneralRe: how to delete selected item from datagrid Pin
yuvachandra23-May-07 2:06
yuvachandra23-May-07 2:06 
GeneralRe: how to delete selected item from datagrid Pin
yuvachandra23-May-07 2:09
yuvachandra23-May-07 2:09 
GeneralRe: how to delete selected item from datagrid Pin
Sherin Iranimose23-May-07 2:38
Sherin Iranimose23-May-07 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.