0

i cant call Response.Redirect On the Webservice Event my code is :

On Page Load

 if (!Page.IsPostBack)
        {
            PublicService.WebService1.Select_Category_By_Type_And_EntityTypeCompleted += WebService1_Select_Category_By_Type_And_EntityTypeCompleted;
            PublicService.WebService1.Search_SuggestCompleted += WebService1_Search_SuggestCompleted;

        }

On Event Code

 if (e.Error == null)
        {
            if (e.Result.Length > 0)
            {
                ViewState["SearchSuggest"] =Language.HelperD.SerializeDataContent( e.Result.ToList());
                Timer1.Enabled = true;
               // Session["SearchSuggest"] = ViewState["SearchSuggest"];
                Response.Redirect("../Suggest/SearchResult.aspx", false);
            }
        }

Error is An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code

Additional information: Response is not available in this context. Response is not available in this context.

Next Error ON set the Session

Error is : Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration

my Config is: see enableSessionState="true" !

<%@ Page Title="" Language="C#" MasterPageFile="~/Base.Master" AutoEventWireup="true" Async="true" EnableSessionState="true" CodeBehind="SearchResult.aspx.cs" Inherits="TourismWeb.Suggest.SearchResult" %>

And....

<pages  theme="DeltaModerno1" controlRenderingCompatibilityVersion="4.0" enableSessionState="true" validateRequest="true" clientIDMode="AutoID" asyncTimeout="999999" enableViewStateMac="false" enableViewState="true">
  <controls>
    <add tagPrefix="dx" namespace="DevExpress.Web" assembly="DevExpress.Web.v16.2, Version=16.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
    <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
  </controls>
</pages>
Arman
  • 47
  • 2
  • 8
  • Where is the `if (e.Error == null) ....` code running? In a web service? If so you need to handle redirecting in the code that calls the webservice after the service has returned the results... – user1429080 Feb 01 '17 at 07:21
  • i check the Webservice Error Its True, no error on Request. – Arman Feb 01 '17 at 07:34

1 Answers1

0

Try accessing via HttpContext:

HttpContext.Current.Response.Redirect("../Suggest/SearchResult.aspx");
CoolBots
  • 4,770
  • 2
  • 16
  • 30
  • maybe fix the Response.Redirect But i Can't set Session["SearchSuggest"] – Arman Feb 01 '17 at 07:51
  • You'll need to implement `IRequireSessionState` interface in the page containing the event handler where you want to access `Session`. More info here: https://msdn.microsoft.com/en-us/library/system.web.sessionstate.irequiressessionstate.aspx – CoolBots Feb 01 '17 at 07:55
  • How can i Use IRequireSessionState ?!! i chech this if if (Context.Handler is IRequiresSessionState) its return true ! – Arman Feb 01 '17 at 10:35
  • @Arman, take a look at this StackOverflow question: http://stackoverflow.com/questions/1375627/irequiressessionstate-how-do-i-use-it – CoolBots Feb 01 '17 at 15:58
  • HttpContext.Current.Session["SearchSuggest"] = ViewState["SearchSuggest"]; HttpContext.Current.Response.Redirect("../Suggest/SearchResult.aspx"); – Arman Feb 01 '17 at 19:30