@@ -519,7 +519,6 @@ public ActionResult Warnings()
519519 }
520520
521521 // sitemap reachability
522- HttpStatusCode ? sitemapStatusCode = null ;
523522 string sitemapUrl = null ;
524523 try
525524 {
@@ -530,35 +529,37 @@ public ActionResult Warnings()
530529
531530 using ( var response = ( HttpWebResponse ) request . GetResponse ( ) )
532531 {
533- sitemapStatusCode = response . StatusCode ;
532+ var status = response . StatusCode ;
533+ var warningModel = new SystemWarningModel ( ) ;
534+ warningModel . Level = ( status == HttpStatusCode . OK ? SystemWarningLevel . Pass : SystemWarningLevel . Warning ) ;
535+
536+ switch ( status )
537+ {
538+ case HttpStatusCode . OK :
539+ warningModel . Text = T ( "Admin.System.Warnings.SitemapReachable.OK" ) ;
540+ break ;
541+ default :
542+ if ( status == HttpStatusCode . MethodNotAllowed )
543+ warningModel . Text = T ( "Admin.System.Warnings.SitemapReachable.MethodNotAllowed" ) ;
544+ else
545+ warningModel . Text = T ( "Admin.System.Warnings.SitemapReachable.Wrong" ) ;
546+
547+ warningModel . Text = string . Concat ( warningModel . Text , " " , T ( "Admin.Common.HttpStatus" , ( int ) status , status . ToString ( ) ) ) ;
548+ break ;
549+ }
550+
551+ model . Add ( warningModel ) ;
534552 }
535553 }
536554 catch ( WebException exception )
537555 {
538- Logger . Warning ( sitemapUrl . IsEmpty ( ) ? "SitemapSEO" : sitemapUrl , exception ) ;
539- }
540-
541- if ( sitemapStatusCode . HasValue && sitemapStatusCode . Value == HttpStatusCode . OK )
542- {
543- model . Add ( new SystemWarningModel
544- {
545- Level = SystemWarningLevel . Pass ,
546- Text = T ( "Admin.System.Warnings.SitemapReachable.OK" )
547- } ) ;
548- }
549- else
550- {
551- var warningText = T ( "Admin.System.Warnings.SitemapReachable.Wrong" ) ;
552- if ( sitemapStatusCode . HasValue )
553- {
554- warningText = string . Concat ( warningText , " " , T ( "Admin.Common.HttpStatus" , ( int ) sitemapStatusCode . Value , sitemapStatusCode . Value . ToString ( ) ) ) ;
555- }
556-
557556 model . Add ( new SystemWarningModel
558557 {
559558 Level = SystemWarningLevel . Warning ,
560- Text = warningText
559+ Text = T ( "Admin.System.Warnings.SitemapReachable.Wrong" )
561560 } ) ;
561+
562+ Logger . Warning ( sitemapUrl . IsEmpty ( ) ? "SitemapSEO" : sitemapUrl , exception ) ;
562563 }
563564
564565 //primary exchange rate currency
0 commit comments