Magento 2 The page isn’t redirecting properly in custom moduleHow can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?main.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?MagentoFrameworkObjectManagerObjectManager givenMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Deleted ShipperHQ module causing error in “All Customers” section of Magento 2

What does the behaviour of water on the skin of an aircraft in flight tell us?

Future enhancements for the finite element method

Mother abusing my finances

Why to use water tanks from Space shuttle in museum?

My player wants to cast multiple charges of magic missile from a wand

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

How can I prevent interns from being expendable?

Get LaTeX form from step by step solution

What does "tea juice" mean in this context?

chmod would set file permission to 000 no matter what permission i try to set

Draw a checker pattern with a black X in the center

Infinitely many hats

Preserving culinary oils

Is the world in Game of Thrones spherical or flat?

Did airlines fly their aircraft slower in response to oil prices in the 1970s?

If I create magical darkness with the Silent Image spell, can I see through it if I have the Devil's Sight warlock invocation?

Is there a rule that prohibits us from using 2 possessives in a row?

Are UK pensions taxed twice?

Team member doesn't give me the minimum time to complete a talk

What is the difference between nullifying your vote and not going to vote at all?

When a current flow in an inductor is interrupted, what limits the voltage rise?

How should I push back against my job assigning "homework"?

Can an old DSLR be upgraded to match modern smartphone image quality

How can I grammatically understand "Wir über uns"?



Magento 2 The page isn’t redirecting properly in custom module


How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?main.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?MagentoFrameworkObjectManagerObjectManager givenMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Deleted ShipperHQ module causing error in “All Customers” section of Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have created the custom module for custom login. But when I open the below link it's not redirecting properly.




http://localhost/magento/custommodule/




below is my route file code and path:



appcodeVendorCustommoduleetcfrontendroutes.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custommodule" frontName="custommodule">
<module name="Vendor_Custommodule" />
</route>
</router>
</config>


layout file path:



appcodeVendorCustommoduleviewfrontendlayoutpressroom_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">pressroom</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
<block class="MagentoCustomerBlockFormLogin" name="customer_form_login" template="form/mycusromlogin.phtml">
<container name="form.additional.info" as="form_additional_info"/>
</block>
</container>
</referenceContainer>
</body>
</page>


appcodeVendorCustommoduleControllerIndexIndex.php



<?php

namespace VendorCustommoduleControllerIndex;

use MagentoFrameworkAppActionContext;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkAppActionAction;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;
protected $urlInterface;


public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
UrlInterface $urlInterface,
MagentoCustomerModelSession $session)

$this->_resultPageFactory = $resultPageFactory;
$this->urlInterface = $urlInterface;
$this->_session = $session;
parent::__construct($context);


public function execute()

$url = $this->urlInterface->getUrl('custommodule/index/index');

// Create login URL
$login_url = $this->urlInterface->getUrl('custommodule/index/index', array('referer' => base64_encode($url))
);
// Redirect to login URL
/** @var MagentoBackendModelViewResultRedirect $resultRedirect */

if(!$this->_session->isLoggedIn())
//echo $login_url.'<br /> here'; die;
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($login_url);
return $resultRedirect;
else
//echo $login_url; die;
$resultPage = $this->_resultPageFactory->create();
return $resultPage;












share|improve this question






















  • What do you mean by not properly rendered? Not at all or is an exception being generated?

    – ooxi
    Jun 15 '17 at 7:58











  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

    – mageDev0688
    Jun 15 '17 at 8:38











  • Sorry I have misread your title as rendered not redirected, shame on me

    – ooxi
    Jun 15 '17 at 8:41











  • Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

    – mageDev0688
    Jun 15 '17 at 8:43











  • Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

    – ooxi
    Jun 15 '17 at 8:43

















0















I have created the custom module for custom login. But when I open the below link it's not redirecting properly.




http://localhost/magento/custommodule/




below is my route file code and path:



appcodeVendorCustommoduleetcfrontendroutes.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custommodule" frontName="custommodule">
<module name="Vendor_Custommodule" />
</route>
</router>
</config>


layout file path:



appcodeVendorCustommoduleviewfrontendlayoutpressroom_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">pressroom</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
<block class="MagentoCustomerBlockFormLogin" name="customer_form_login" template="form/mycusromlogin.phtml">
<container name="form.additional.info" as="form_additional_info"/>
</block>
</container>
</referenceContainer>
</body>
</page>


appcodeVendorCustommoduleControllerIndexIndex.php



<?php

namespace VendorCustommoduleControllerIndex;

use MagentoFrameworkAppActionContext;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkAppActionAction;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;
protected $urlInterface;


public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
UrlInterface $urlInterface,
MagentoCustomerModelSession $session)

$this->_resultPageFactory = $resultPageFactory;
$this->urlInterface = $urlInterface;
$this->_session = $session;
parent::__construct($context);


public function execute()

$url = $this->urlInterface->getUrl('custommodule/index/index');

// Create login URL
$login_url = $this->urlInterface->getUrl('custommodule/index/index', array('referer' => base64_encode($url))
);
// Redirect to login URL
/** @var MagentoBackendModelViewResultRedirect $resultRedirect */

if(!$this->_session->isLoggedIn())
//echo $login_url.'<br /> here'; die;
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($login_url);
return $resultRedirect;
else
//echo $login_url; die;
$resultPage = $this->_resultPageFactory->create();
return $resultPage;












share|improve this question






















  • What do you mean by not properly rendered? Not at all or is an exception being generated?

    – ooxi
    Jun 15 '17 at 7:58











  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

    – mageDev0688
    Jun 15 '17 at 8:38











  • Sorry I have misread your title as rendered not redirected, shame on me

    – ooxi
    Jun 15 '17 at 8:41











  • Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

    – mageDev0688
    Jun 15 '17 at 8:43











  • Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

    – ooxi
    Jun 15 '17 at 8:43













0












0








0








I have created the custom module for custom login. But when I open the below link it's not redirecting properly.




http://localhost/magento/custommodule/




below is my route file code and path:



appcodeVendorCustommoduleetcfrontendroutes.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custommodule" frontName="custommodule">
<module name="Vendor_Custommodule" />
</route>
</router>
</config>


layout file path:



appcodeVendorCustommoduleviewfrontendlayoutpressroom_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">pressroom</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
<block class="MagentoCustomerBlockFormLogin" name="customer_form_login" template="form/mycusromlogin.phtml">
<container name="form.additional.info" as="form_additional_info"/>
</block>
</container>
</referenceContainer>
</body>
</page>


appcodeVendorCustommoduleControllerIndexIndex.php



<?php

namespace VendorCustommoduleControllerIndex;

use MagentoFrameworkAppActionContext;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkAppActionAction;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;
protected $urlInterface;


public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
UrlInterface $urlInterface,
MagentoCustomerModelSession $session)

$this->_resultPageFactory = $resultPageFactory;
$this->urlInterface = $urlInterface;
$this->_session = $session;
parent::__construct($context);


public function execute()

$url = $this->urlInterface->getUrl('custommodule/index/index');

// Create login URL
$login_url = $this->urlInterface->getUrl('custommodule/index/index', array('referer' => base64_encode($url))
);
// Redirect to login URL
/** @var MagentoBackendModelViewResultRedirect $resultRedirect */

if(!$this->_session->isLoggedIn())
//echo $login_url.'<br /> here'; die;
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($login_url);
return $resultRedirect;
else
//echo $login_url; die;
$resultPage = $this->_resultPageFactory->create();
return $resultPage;












share|improve this question














I have created the custom module for custom login. But when I open the below link it's not redirecting properly.




http://localhost/magento/custommodule/




below is my route file code and path:



appcodeVendorCustommoduleetcfrontendroutes.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custommodule" frontName="custommodule">
<module name="Vendor_Custommodule" />
</route>
</router>
</config>


layout file path:



appcodeVendorCustommoduleviewfrontendlayoutpressroom_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">pressroom</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
<block class="MagentoCustomerBlockFormLogin" name="customer_form_login" template="form/mycusromlogin.phtml">
<container name="form.additional.info" as="form_additional_info"/>
</block>
</container>
</referenceContainer>
</body>
</page>


appcodeVendorCustommoduleControllerIndexIndex.php



<?php

namespace VendorCustommoduleControllerIndex;

use MagentoFrameworkAppActionContext;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkAppActionAction;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;
protected $urlInterface;


public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
UrlInterface $urlInterface,
MagentoCustomerModelSession $session)

$this->_resultPageFactory = $resultPageFactory;
$this->urlInterface = $urlInterface;
$this->_session = $session;
parent::__construct($context);


public function execute()

$url = $this->urlInterface->getUrl('custommodule/index/index');

// Create login URL
$login_url = $this->urlInterface->getUrl('custommodule/index/index', array('referer' => base64_encode($url))
);
// Redirect to login URL
/** @var MagentoBackendModelViewResultRedirect $resultRedirect */

if(!$this->_session->isLoggedIn())
//echo $login_url.'<br /> here'; die;
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($login_url);
return $resultRedirect;
else
//echo $login_url; die;
$resultPage = $this->_resultPageFactory->create();
return $resultPage;









magento2 customer-account redirection






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 15 '17 at 7:27









mageDev0688mageDev0688

370728




370728












  • What do you mean by not properly rendered? Not at all or is an exception being generated?

    – ooxi
    Jun 15 '17 at 7:58











  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

    – mageDev0688
    Jun 15 '17 at 8:38











  • Sorry I have misread your title as rendered not redirected, shame on me

    – ooxi
    Jun 15 '17 at 8:41











  • Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

    – mageDev0688
    Jun 15 '17 at 8:43











  • Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

    – ooxi
    Jun 15 '17 at 8:43

















  • What do you mean by not properly rendered? Not at all or is an exception being generated?

    – ooxi
    Jun 15 '17 at 7:58











  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

    – mageDev0688
    Jun 15 '17 at 8:38











  • Sorry I have misread your title as rendered not redirected, shame on me

    – ooxi
    Jun 15 '17 at 8:41











  • Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

    – mageDev0688
    Jun 15 '17 at 8:43











  • Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

    – ooxi
    Jun 15 '17 at 8:43
















What do you mean by not properly rendered? Not at all or is an exception being generated?

– ooxi
Jun 15 '17 at 7:58





What do you mean by not properly rendered? Not at all or is an exception being generated?

– ooxi
Jun 15 '17 at 7:58













It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

– mageDev0688
Jun 15 '17 at 8:38





It's not redirecting properly. it's showing the The page isn’t redirecting properly error.

– mageDev0688
Jun 15 '17 at 8:38













Sorry I have misread your title as rendered not redirected, shame on me

– ooxi
Jun 15 '17 at 8:41





Sorry I have misread your title as rendered not redirected, shame on me

– ooxi
Jun 15 '17 at 8:41













Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

– mageDev0688
Jun 15 '17 at 8:43





Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login.

– mageDev0688
Jun 15 '17 at 8:43













Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

– ooxi
Jun 15 '17 at 8:43





Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login

– ooxi
Jun 15 '17 at 8:43










1 Answer
1






active

oldest

votes


















0














You should change layout name pressroom_index_index to custommodule_index_index



Not test you but you should try redirect like below



public function execute() 
--- concat ---

$resultRedirect->setUrl('custommodule/index/index');

--- concat ---






share|improve this answer























  • Thanks for your answer, I had solved this issue at my end.

    – mageDev0688
    Jun 19 '17 at 5:08











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f179142%2fmagento-2-the-page-isn-t-redirecting-properly-in-custom-module%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You should change layout name pressroom_index_index to custommodule_index_index



Not test you but you should try redirect like below



public function execute() 
--- concat ---

$resultRedirect->setUrl('custommodule/index/index');

--- concat ---






share|improve this answer























  • Thanks for your answer, I had solved this issue at my end.

    – mageDev0688
    Jun 19 '17 at 5:08















0














You should change layout name pressroom_index_index to custommodule_index_index



Not test you but you should try redirect like below



public function execute() 
--- concat ---

$resultRedirect->setUrl('custommodule/index/index');

--- concat ---






share|improve this answer























  • Thanks for your answer, I had solved this issue at my end.

    – mageDev0688
    Jun 19 '17 at 5:08













0












0








0







You should change layout name pressroom_index_index to custommodule_index_index



Not test you but you should try redirect like below



public function execute() 
--- concat ---

$resultRedirect->setUrl('custommodule/index/index');

--- concat ---






share|improve this answer













You should change layout name pressroom_index_index to custommodule_index_index



Not test you but you should try redirect like below



public function execute() 
--- concat ---

$resultRedirect->setUrl('custommodule/index/index');

--- concat ---







share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 19 '17 at 2:04









mrtuvnmrtuvn

1,91411830




1,91411830












  • Thanks for your answer, I had solved this issue at my end.

    – mageDev0688
    Jun 19 '17 at 5:08

















  • Thanks for your answer, I had solved this issue at my end.

    – mageDev0688
    Jun 19 '17 at 5:08
















Thanks for your answer, I had solved this issue at my end.

– mageDev0688
Jun 19 '17 at 5:08





Thanks for your answer, I had solved this issue at my end.

– mageDev0688
Jun 19 '17 at 5:08

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f179142%2fmagento-2-the-page-isn-t-redirecting-properly-in-custom-module%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form